Open io7m opened 3 years ago
Hi. Could you include the output of gradle --version
? Thanks.
Oops, yes:
$ ./gradlew --version
------------------------------------------------------------
Gradle 6.5
------------------------------------------------------------
Build time: 2020-06-02 20:46:21 UTC
Revision: a27f41e4ae5e8a41ab9b19f8dd6d86d7b384dad4
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 11.0.10 (Oracle Corporation 11.0.10+9)
OS: Linux 5.10.11-arch1-1 amd64
We're not tied to this specific version of Gradle. We have multiple projects all using different versions, and we can pretty much upgrade to anything that isn't Gradle 7 at any point. Is there a particular version you recommend?
AFAICT the enforcer-gradle-plugin
works for Java projects using Gradle 6.x. For Android projects things might be different as all bets are off, the Android plugin provides a structure similar to the java/java-library plugins but it's not the same.
Have you tried configuring the enforcer plugin in the build (using settings.gradle
) instead of configuring in a project?
Android plugin
The Android plugin is a gift that just keeps on giving and giving and giving. Most of our attempts to keep our builds stable, reliable, reproducible, etc, have been thwarted by things that plugin introduces. :weary:
I'll try configuring things in settings.gradle
and see if that changes anything.
Ouch. Configuring it in settings.gradle
:
Could not resolve all files for configuration ':simplified-accessibility:apiDependenciesMetadataCopy'.
> Could not resolve project :simplified-books-registry-api.
Required by:
project :simplified-accessibility
> The consumer was configured to find a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common'. However we cannot choose between the following variants of project :simplified-books-registry-api:
- debugAndroidTestCompile
- debugAndroidTestRuntime
- debugApiElements
- debugRuntime
- debugRuntimeElements
- debugUnitTestCompile
- debugUnitTestRuntime
- releaseApiElements
- releaseRuntime
- releaseRuntimeElements
- releaseUnitTestCompile
- releaseUnitTestRuntime
All of them match the consumer attributes:
- Variant 'debugAndroidTestCompile' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-books-registry-api' but the consumer didn't ask for it
- Variant 'debugAndroidTestRuntime' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-books-registry-api' but the consumer didn't ask for it
- Variant 'debugApiElements' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but the consumer didn't ask for it
- Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
- Variant 'debugRuntime' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-books-registry-api' but the consumer didn't ask for it
- Variant 'debugRuntimeElements' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a runtime of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but the consumer didn't ask for it
- Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
- Variant 'debugUnitTestCompile' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-books-registry-api' but the consumer didn't ask for it
- Variant 'debugUnitTestRuntime' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-books-registry-api' but the consumer didn't ask for it
- Variant 'releaseApiElements' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' but the consumer didn't ask for it
- Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it
- Variant 'releaseRuntime' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-books-registry-api' but the consumer didn't ask for it
- Variant 'releaseRuntimeElements' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a runtime of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' but the consumer didn't ask for it
- Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it
- Variant 'releaseUnitTestCompile' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-books-registry-api' but the consumer didn't ask for it
- Variant 'releaseUnitTestRuntime' capability org.librarysimplified:simplified-books-registry-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-books-registry-api' but the consumer didn't ask for it
> Could not resolve project :simplified-ui-thread-api.
Required by:
project :simplified-accessibility
> The consumer was configured to find a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common'. However we cannot choose between the following variants of project :simplified-ui-thread-api:
- debugAndroidTestCompile
- debugAndroidTestRuntime
- debugApiElements
- debugRuntime
- debugRuntimeElements
- debugUnitTestCompile
- debugUnitTestRuntime
- releaseApiElements
- releaseRuntime
- releaseRuntimeElements
- releaseUnitTestCompile
- releaseUnitTestRuntime
All of them match the consumer attributes:
- Variant 'debugAndroidTestCompile' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-ui-thread-api' but the consumer didn't ask for it
- Variant 'debugAndroidTestRuntime' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-ui-thread-api' but the consumer didn't ask for it
- Variant 'debugApiElements' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but the consumer didn't ask for it
- Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
- Variant 'debugRuntime' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-ui-thread-api' but the consumer didn't ask for it
- Variant 'debugRuntimeElements' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a runtime of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but the consumer didn't ask for it
- Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
- Variant 'debugUnitTestCompile' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-ui-thread-api' but the consumer didn't ask for it
- Variant 'debugUnitTestRuntime' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-ui-thread-api' but the consumer didn't ask for it
- Variant 'releaseApiElements' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' but the consumer didn't ask for it
- Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it
- Variant 'releaseRuntime' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-ui-thread-api' but the consumer didn't ask for it
- Variant 'releaseRuntimeElements' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a runtime of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' but the consumer didn't ask for it
- Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it
- Variant 'releaseUnitTestCompile' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-ui-thread-api' but the consumer didn't ask for it
- Variant 'releaseUnitTestRuntime' capability org.librarysimplified:simplified-ui-thread-api:6.6.4-SNAPSHOT declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Doesn't say anything about its usage (required a usage of 'kotlin-api')
- Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :simplified-ui-thread-api' but the consumer didn't ask for it
This is quite unfortunate. The plugin was designed to work with Java projects, honestly I never tested it with Android projects. You could try listing those configurations that should be checked with https://kordamp.org/enforcer-gradle-plugin/#_properties_17
Unfortunately this is an includes list. In your case it might be easier if there was an exclude list as the error tells you exactly which configuration is failing.
Hi, I've encountered this issue too, and I created minimal configuration that can be used to recreate it. It's reproducible with Gradle 6 and without Android.
So, create a root project with 2 subprojects
rootProject.name = 'parent-module'
include 'child-module'
include 'child-module2'
In child-module add following configuration:
plugins {
id 'java'
id 'org.kordamp.gradle.project-enforcer' version '0.9.0'
}
configurations {
myconfig {
canBeConsumed = false
canBeResolved = true
}
}
repositories {
mavenCentral()
}
dependencies {
myconfig project(':child-module2')
implementation "org.apache.shiro:shiro-guice:1.7.1"
implementation "org.jboss.resteasy:resteasy-multipart-provider:4.6.0.Final"
}
enforce {
rule(enforcer.rules.BanDuplicateClasses) { r ->
r.findAllDuplicates = true
r.ignoreWhenIdentical = true
}
}
This is enough to recreate the issue. Configuration in root project and child-module2 doesn't matter - they can be almost empty, without dependencies.
The key here is custom configuration myconfig
.
This also happens with nested modules:
settings.gradle:
include 'level1:level2'
build.gradle:
plugins {
id 'java'
id 'org.kordamp.gradle.project-enforcer' version '0.9.0'
}
repositories {
mavenCentral()
}
dependencies {
implementation project(":level1:level2")
}
enforce {
rule(enforcer.rules.BanDuplicateClasses) { r ->
}
}
level1/build.gradle: empty, or even absent.
level1/level2/build.gradle:
plugins {
id 'java'
}
And I get this error:
A problem occurred configuring root project 'enforce-test'.
> Could not resolve all dependencies for configuration ':compileClasspathCopy'.
> A problem occurred configuring project ':level1:level2'.
> Cannot notify listeners of type ProjectEvaluationListener as these listeners are already being notified.
In this case I have to use the Build mode of this plugin, i.e., put this in settings.gradle:
settings.gradle:
include 'level1:level2'
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'org.kordamp.gradle:enforcer-gradle-plugin:0.9.0'
}
}
apply plugin: 'org.kordamp.gradle.enforcer'
enforce {
rule(enforcer.rules.BanDuplicateClasses) { r ->
}
}
and removes the plugin from build.gradle.
Happens for us as well in a multi-project build.
I can add it to one of the projects just fine. If I try to add it to a second project, that breaks with exactly this message.
I suspect that it could be related to some quite heavy usage of evaluationDependsOn in our build scripts... :|
Hello!
We're trying to use this plugin in the Library Simplified Android project to reject
-SNAPSHOT
dependencies. Unfortunately, we're running into an error.If I add the following to the
build.gradle
file at the top level:I get a rather useless error from Gradle:
Do you have any idea as to what we can do about this?