Giter VIP home page Giter VIP logo

gradle-version-catalogs's Introduction

red_mad_robot Version Catalogs

Version

Shared catalogs used in red_mad_robot android team. Gradle 7.4 required.


Catalogs

Usage

You can read more about shared catalogs usage in the documentation.

You need to create version catalogs in settings.gradle.kts from remote repository:

dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }

    versionCatalogs {
        val version = "2023.05.18"
        create("rmr") {
            from("com.redmadrobot.versions:versions-redmadrobot:$version")
        }
        create("androidx") {
            from("com.redmadrobot.versions:versions-androidx:$version")
        }
        create("stack") {
            from("com.redmadrobot.versions:versions-stack:$version")
        }
    }
}

โš ๏ธ Be careful with version catalogs naming. Make sure selected name does not conflict with any of Gradle plugin extensions, otherwise your project will not sync. For example, if you have gradle-infrastructure plugin, you cannot create version catalog named redmadrobot, because gradle-infrastructure contains an extension named redmadrobot. Also you should not name the published version catalog as libs if you want to use the local version catalog, or you must rename the local version catalog.

After sync the project gradle create accessors for dependencies like:

plugins {
    alias(rmr.plugins.application)
    alias(androidx.plugins.navigation.safeargs.kotlin)
}

dependencies {
    implementation(androidx.core)
    implementation(androidx.fragment)

    implementation(rmr.ktx.fragment)

    implementation(stack.dagger)
}

Troubleshooting

You can find Troubleshooting in gradle documentation page.

Unable to apply the plugin because the extension is already registered

Caused by: java.lang.IllegalArgumentException: Cannot add extension with name, as there is an extension already registered with that name

Probably, you named a version catalog as one of the gradle plugin extensions. Please, read the warning under Usage section.

Unable to apply a plugin from the version catalog due to a version conflict to the classpath

Caused by: org.gradle.plugin.management.internal.InvalidPluginRequestException: Plugin request for plugin already on the classpath must not include a version

This exception can occur if the plugin has already been applied in the root build.gradle, or has a notation in the buildscripts section, or has a notation in the plugins section of the settings.gradle file. You can leave the plugin notation only in the modules you need, because alias applies the plugin version from the version catalog file. If this is not possible, you can use the id extension instead of alias and get only pluginId from the accessor.

plugins {
  id(rmr.plugins.detekt.get().pluginId)
}

DSL_SCOPE_VIOLATION can't be called in this context by implicit receiver

This is an Intellij IDEA issue and it does not affect the build. You can suppress it with @Suppress("DSL_SCOPE_VIOLATION")

Invalid catalog definition

Problem: In version catalog libs, you can only import a single external catalog in a given catalog definition.

Probably, you named a published version catalog as libs. Please, read the warning under Usage section.

Invalid TOML catalog definition

Check your Gradle wrapper version. The current catalog based on Gradle 7.2.

Additional links

gradle-version-catalogs's People

Contributors

osipxd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.