Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle expects guice no_aop component but is not found in Guice 5.0.1 #82

Open
Dhivyaa21 opened this issue Apr 28, 2022 · 9 comments
Open
Assignees

Comments

@Dhivyaa21
Copy link
Contributor

Current Behavior

Gradle complains about no_aop component of Guice 5.0.1

Context

This issue results in exception during gradle dependency resolution.

Your Environment

My dependencies block

dependencies {
  implementation 'io.github.cdancy:artifactory-rest:1.0.0'
  testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
  testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}

The only dependency that pulls Guice is the artifactory-rest.

Downgrading Guice to 4.2.2 resolves this issue but I would like to know if it will be downgraded in your library.

@martinda
Copy link
Contributor

martinda commented May 5, 2022

It appears to be related to google/guice#1505

@cdancy
Copy link
Owner

cdancy commented May 5, 2022

@Dhivyaa21 thanks for reporting. @martinda we could add a dependency on the relevant library. What do you think? I don't see any other options and don't think it's wrong in any sense.

@martinda
Copy link
Contributor

martinda commented May 6, 2022

Here is the smallest build.gradle file that can reproduce the issue:

plugins {
    id 'java-library'
    id 'application'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'io.github.cdancy:artifactory-rest:1.0.0'
    implementation 'org.codehaus.groovy:groovy-all:3.0.5'
}

Reproduce with: gradle clean build

* What went wrong:
Execution failed for task ':startScripts'.
> Error while evaluating property 'relativeClasspath' of task ':startScripts'
   > Could not resolve all files for configuration ':runtimeClasspath'.
      > Could not find guice-5.0.1-no_aop.jar (com.google.inject:guice:5.0.1).
        Searched in the following locations:
            https://repo.maven.apache.org/maven2/com/google/inject/guice/5.0.1/guice-5.0.1-no_aop.jar

The error goes away when I comment out the application plugin or the groovy-all dependency.

@martinda
Copy link
Contributor

martinda commented May 6, 2022

Upgrading to a minimum of groovy-all:3.0.6 appears to fix the issue. I tried 3.0.6 through to 3.0.10, and going back to 3.0.5. I don't understand where this was fixed exactly, but it looks like it was fixed with groovy 3.0.6.

@martinda
Copy link
Contributor

martinda commented May 9, 2022

google/guice#1073

@martinda
Copy link
Contributor

I wrote this gist and it tells me what brings the no_aop artifact. It's caused by groovy-all:3.0.5:

    org.codehaus.groovy:groovy-all:3.0.5;runtime
        Resolved dependencies:
        org.codehaus.groovy:groovy-testng:3.0.5;runtime
            Artifacts:
            groovy-testng-3.0.5.jar (org.codehaus.groovy:groovy-testng:3.0.5)
            Resolved dependencies:
            org.testng:testng:7.1.0;runtime
                Artifacts:
                testng-7.1.0.jar (org.testng:testng:7.1.0)
                Resolved dependencies:
                com.google.inject:guice:5.0.1;runtime
                    Artifacts:
                    guice-5.0.1-no_aop.jar (com.google.inject:guice:5.0.1)

Gradle certainly did not make this one easy.

@c00ler
Copy link

c00ler commented Sep 8, 2022

@martinda In Gradle, it's possible to substitute the dependency. More about it here.
In the case of guice it's possible to replace no_aop with the unclassified version, using the following configuration:

configurations.all {
    resolutionStrategy.dependencySubstitution {
        substitute module('com.google.inject:guice') using module('com.google.inject:guice:5.0.1') withoutClassifier()
    }
}

Hope it helps.

@martinda
Copy link
Contributor

martinda commented Sep 8, 2022

Upgrading to groovy-all:3.0.6 or higher works (I tried 3.0.6 and 3.0.12, as well as org.apache.groovy:groovy-all:4.0.4). So it's not really an issue for artifactory-rest to fix.

@jiridanek
Copy link

jiridanek commented Oct 13, 2023

configurations.all {
    resolutionStrategy.dependencySubstitution {
        substitute module('com.google.inject:guice') using module('com.google.inject:guice:5.0.1') withoutClassifier()
    }
}

I'm using Kotlin DSL and the Kotlin-equivalent of this did not seem to be removing the classifier. (The result of the code below tries to get guice 5.0.0, but still with the no_aop, for me, so it works partially.)

configurations.all {
    resolutionStrategy.dependencySubstitution {
        substitute(module("com.google.inject:guice:6.0.0")).using((module("com.google.inject:guice:5.0.0"))).withoutArtifactSelectors().withoutClassifier()
    }
}

What worked for me was an approach from https://discuss.gradle.org/t/remove-transitive-dependency-with-classifier-and-replace-with-new-one-without-classifier/26324/5

configurations.all {
    // guice 5.x stopped shipping no_aop jar
    resolutionStrategy.eachDependency {
        if (this.requested.module.toString() == "com.google.inject:guice") {
            this.artifactSelection {
                this.selectArtifact(DependencyArtifact.DEFAULT_TYPE, null, null)
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants