Open hansinator85 opened 6 years ago
I think you are seeing the same issue I am seeing and reported here as well. I actually have had a support ticket open since the release of 3.0 to the masses. I think it has to do with how they parse everything for POM generation.
@hansinator85, @cfsbhawkins, We have created a new example that works with the latest Android gradle plugin, see the example here.
Command line to run the example:
./gradlew clean artifactoryPublish
Output:
> Task :app:lint
Ran lint on variant release: 3 issues found
Ran lint on variant debug: 3 issues found
Wrote HTML report to file:///home/romang/Work/Devdir/DEV1/project-examples/gradle-examples/4/gradle-android-example/app/build/reports/lint-results.html
Wrote XML report to file:///home/romang/Work/Devdir/DEV1/project-examples/gradle-examples/4/gradle-android-example/app/build/reports/lint-results.xml
> Task :library:lint
Ran lint on variant debug: 2 issues found
Ran lint on variant release: 2 issues found
Wrote HTML report to file:///home/romang/Work/Devdir/DEV1/project-examples/gradle-examples/4/gradle-android-example/library/build/reports/lint-results.html
Wrote XML report to file:///home/romang/Work/Devdir/DEV1/project-examples/gradle-examples/4/gradle-android-example/library/build/reports/lint-results.xml
> Task :library:artifactoryPublish
Deploying artifact: http://localhost:8081/artifactory/libs-snapshot-local/gradle-android-example/app/1.0-SNAPSHOT/app-1.0-SNAPSHOT.apk
Deploying artifact: http://localhost:8081/artifactory/libs-snapshot-local/gradle-android-example/app/1.0-SNAPSHOT/app-1.0-SNAPSHOT.pom
Deploying artifact: http://localhost:8081/artifactory/libs-snapshot-local/gradle-android-example/library/1.0-SNAPSHOT/library-1.0-SNAPSHOT.aar
Deploying artifact: http://localhost:8081/artifactory/libs-snapshot-local/gradle-android-example/library/1.0-SNAPSHOT/library-1.0-SNAPSHOT.pom
Deploying build descriptor to: http://localhost:8081/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under http://localhost:8081/artifactory/webapp/builds/gradle-android-example/1512485352762
BUILD SUCCESSFUL in 22s
118 actionable tasks: 114 executed, 4 up-to-date
Can you please try running the example, it might help us troubleshot the issues you are having.
Do we have to have the following line?
artifactoryPublish.dependsOn('build')
Problem I have with this is the fact that this now build debug, release, all of my build flavors runs lint and tests.
I would prefer to do as I used to since this is done via a CI machine and call ./gradlew assembleDebug artifactoryPublish and it just upload the resulting artifacts from the previous build.
Problem I have with requiring my artifactoryPublish to run my builds is this now takes over 8 minutes on my machine to build. (I have a lot of modules and product variants)
@cfsbhawkins,
You don't have to add the artifactoryPublish.dependsOn('build')
dependency.
But before executing artifactoryPublish
make sure the artifacts in the publication exist, otherwise it will fail.
@romangurevitch your example link is broken... could you restore it, please?
@billyjoker, Sure here it is: gradle-android-example.
I am also getting this problem. I have created a sample project that should help replicate the issue:
I am having exactly the same problem. And just that we don't go in the wrong direction, I am not using any publishing config inside of the project (all deployment config is hapening in jenkins). I am only having my build config in Gradle, so I don't think the publishing config is causing is issue... I have many modules and I am using a lot of dependencies, one of them is Firebase. I am doubting this is related to Firebase.
Hi, we're seeing the same issue with the Jenkins Artifactory plugin 2.16.1. We don't use the Artifactory Gradle plugin in our Gradle file directly but rather the Jenkins plugin. The builds started to fail with the same/similar failure:
Error during extraction:
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':mobile:flavourCompileClasspath'.
...
Caused by: org.gradle.internal.component.AmbiguousVariantSelectionException: More than one variant of project :library matches the consumer attributes:
...
Just in case, it's an Android project that has multiple Gradle modules and uses Gradle 4.6 & com.android.tools.build:gradle:3.1.2
I reproduced this issue using the sample project provided by @agent826 (Thanks you @agent826). This exception is thrown by the resolvedConfiguration.getResolvedArtifacts() gradle API. See the below code snippet which uses this API in the org.jfrog.gradle.plugin.artifactory.extractor.GradleBuildInfoExtractor class.
private List<Dependency> calculateDependencies(Project project) throws Exception {
Set<Configuration> configurationSet = project.getConfigurations();
List<Dependency> dependencies = newArrayList();
for (Configuration configuration : configurationSet) {
if (configuration.getState() != Configuration.State.RESOLVED) {
log.info("Artifacts for configuration '{}' were not all resolved, skipping", configuration.getName());
continue;
}
ResolvedConfiguration resolvedConfiguration = configuration.getResolvedConfiguration();
Set<ResolvedArtifact> resolvedArtifactSet = resolvedConfiguration.getResolvedArtifacts();
I opened issue https://github.com/gradle/gradle/issues/5426 to the gradle team, hoping to get some guidance on the best approach to handle this exception.
Does anyone found at least a workaround to this?
This is biting us too and we wonder does anybody at least know a way to work around this?
I'm also getting this issue. I've reached out to JFrog Support email but haven't heard anything yet.
I also got the same issue, using android gradle plugin 4.0.0. I got 3 modules: app, demo and library itself. app is used for visual and demo and library are both libs.
My workaround is to not use this plugin. I switched to the maven-publish
plugin, which also can easily build the AAR and POM files since Android Studio 3.6. Just add a repositories
section to the config. As a bonus, it also publishes the Gradle module metadata, which is a new format similar to POM.
Plugin documentation: https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven
Greetings from the world of tomorrow! This is still happening in late 2021 with the latest plugin version 4.24.23
EDIT: this issue can be trivially reproduced using the sample project https://github.com/jfrog/project-examples/tree/master/gradle-examples/gradle-android-example by adding a second library module e.g. lib2 and then add a project dependency on 'lib2' in the 'library' module's build.gradle e.g.
implementation project(path: ':lib2')
EDIT2: it's possible to work around this issue by changing the project dependency to
implementation project(path: ':lib2', configuration: 'default')
per the discussion at https://github.com/sonatype-nexus-community/scan-gradle-plugin/issues/41#issuecomment-686795853, which incidentally is a plugin that had this problem and apparently fixed it. Not sure what the configuration arg is doing or why this helps, but it seems to.
Hi. I'm still facing this problem with plugin version 4.29.0 and the work around seems to cause other issues. Basically, when adding the specific default
configuration, I begin to get unresolved references when trying to access anything in the dependency in question.
Has there been any progress on resolving? Or any other potential workarounds (other than not using the plugin)?
Hi. I'm still facing this problem with plugin version 4.29.0 and the work around seems to cause other issues. Basically, when adding the specific
default
configuration, a being to get unresolved references when trying to access anything in the dependency in question.Has the been any progress on resolving? Or any other potential workarounds (other than not using the plugin)?
IIRC the 'solution' I went with was to remove the from components.mybuildvariant
from my Maven publication definition and instead manually write out my transitive dependencies to the POM file with
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each
configurations.implementation.allDependencies.each {
// need to check if the dependency is sane before writing it in; sometimes
// local deps (project or prebuilts in libs dir etc.) will come in with unspecified
// properties, which means they need special handling
if (it.version.toString().toLowerCase() != "unspecified"
&& it.name.toString().toLowerCase() != "unspecified"
&& it.group.toString().toLowerCase() != "unspecified") {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
For whatever reason, when I don't use the from components...
API this bug doesn't occur (at least in build-info plugin v4.24.23).
Hi, I am still facing the issue with plugin 7.4.2 version. Even with maven publish, I am getting the error.Are there any alternative workarounds that have been successful in resolving this issue for others?
@Sanheethaa, This issue should be fixed in the Gradle Artifactory plugin 5.1.0 by https://github.com/jfrog/artifactory-gradle-plugin/pull/46. Please feel free to upgrade to the latest version and share your feedback.
@Sanheethaa what is your Gradle Artifactory plugin version?
@Sanheethaa what is your Gradle Artifactory plugin version?
That was 4.24.9. With 5.1.0, the issue is not seen. thank you so much.
Since upgrading to Android Gradle 3.0 (actually 3.0.1) with Gradle 4.3 we are not getting dependencies anymore.
The build info is not showing any dependencies. When doing the
artifactoryPublish
with--debug
we see the following error occur (might be the issue?):We have a multi module project with kind of following structure (i'll try to describe as good as possible, can't give you the project of course and would take some time to construct a sample):
Working old configuration with Android Gradle 2.3.3 and Gradle 3.3
publishNonDefault true dependencies { releaseCompile project(path: ':library2', configuration: 'release') debugCompile project(path: ':library2', configuration: 'debug') }
dependencies { releaseCompile project(path: ':library1 ', configuration: 'release') debugCompile project(path: ':library1 ', configuration: 'debug') }
dependencies { api 'com.google.guava:guava:' + rootProject.ext.guavaVersion api 'com.squareup.okhttp3:okhttp:' + rootProject.ext.OKHttpClientVersion api 'com.squareup.okio:okio:' + rootProject.ext.OKIOVersion ... }
dependencies { api project(':library2') }
dependencies { api project(':library1') }