Skip to content

Conversation

@pzygielo
Copy link
Contributor

@pzygielo pzygielo commented May 1, 2020

I propose this change to resolve MDEP-680.

My understanding is as follows:

  1. both o.a.m...internal.Maven30DependencyResolver.resolveDependencies and o.a.m...internal.Maven31DependencyResolver.resolveDependencies use buildingRequest.getRemoteRepositories()
  2. ResolvePluginsMojo sets them explicitly:
    buildingRequest.setRemoteRepositories( this.remotePluginRepositories );
    but GoOffline doesn't. Thus as I observed effectively only central is used.

I recorded my steps of the preparation, actual fix and some clean-up in separate commits.

I'm pretty sure about the code change, as I successfully used new go-offline from snapshot plugin with several (multi-module, parent-child) projects with dependencies and plugins from multiple (i.e. non-central) repositories.


@pzygielo pzygielo marked this pull request as ready for review May 1, 2020 20:12
@tylerwilding-wk
Copy link

We have also been experiencing problems using go-offline since the 3.1.2 release, specifically when trying to resolve netty.

Unfortunately when I pulled down these changes and built the plugin locally, I get the same error. Perhaps this is another separate issue related to go-offline changes?

Using a blank pom.xml with only the latest netty dependency and the dependency plugin:

...
    <dependencies>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.1.49.Final</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.2</version>
            </plugin>
        </plugins>
    </build>
...

Using 3.1.2:

[INFO] --- maven-dependency-plugin:3.1.2:go-offline (default-cli) @ maven-test ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.340 s
[INFO] Finished at: 2020-05-08T10:01:59-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline (default-cli) on project maven-test: org.eclipse.aether.resolution.DependencyResolutionException: The following artifacts could not be resolved: io.netty:netty-tcnative:jar:${os.detected.classifier}:2.0.30.Final, io.netty:netty-transport-native-kqueue:jar:${os.detected.name}-${os.detected.arch}:4.1.49.Final: Failure to find io.netty:netty-tcnative:jar:${os.detected.classifier}:2.0.30.Final in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

Using these changes:

INFO] --- maven-dependency-plugin:3.1.3-LOCAL:go-offline (default-cli) @ maven-test ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.602 s
[INFO] Finished at: 2020-05-08T10:02:33-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.3-LOCAL:go-offline (default-cli) on project maven-test: org.eclipse.aether.resolution.DependencyResolutionException: The following artifacts could not be resolved: io.netty:netty-tcnative:jar:${os.detected.classifier}:2.0.30.Final, io.netty:netty-transport-native-kqueue:jar:${os.detected.name}-${os.detected.arch}:4.1.49.Final: Failure to find io.netty:netty-tcnative:jar:${os.detected.classifier}:2.0.30.Final in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

Which builds successfully on 3.1.1:

INFO] --- maven-dependency-plugin:3.1.1:go-offline (default-cli) @ maven-test ---
[INFO] Resolved: netty-all-4.1.49.Final.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.258 s
[INFO] Finished at: 2020-05-08T10:04:29-04:00
[INFO] ------------------------------------------------------------------------

@pzygielo
Copy link
Contributor Author

pzygielo commented May 8, 2020

Perhaps this is another separate issue related to go-offline changes?

Perhaps it is. You can check existing ones and if none covers your case you can submit new.

But I think it is due to feature MDEP-204: Transitively resolve both dependencies and plugins delivered in 3.1.2 that exposes that io.netty:netty-parent:4.1.49.Final (parent of dependency you use) references undefined os.detected.name and os.detected.arch properties.

Try:

mvn dependency:go-offline -Dos.detected.name=linux -Dos.detected.arch=x86_64

and you'll get all resolved.
(Or use in your project the same build extension as netty-parent does - kr.motd.maven:os-maven-plugin to set them).

@tylerwilding-wk
Copy link

(Or use in your project the same build extension as netty-parent does - kr.motd.maven:os-maven-plugin to set them).

Thank you for this suggestion, that solved the problem. And then consuming the fixes here via your jitpack release was necessary to resolve our non-maven central dependencies. 👍

@pzygielo
Copy link
Contributor Author

May I ask for review, please?

@michael-o
Copy link
Member

I will have a look this night, can't promise I can understand the issue or the patch.

Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can you apply our formatting to the test code?
  2. Retain using log as-is w/o String#format(). This needs to be fixed all in go as soon as it replaced with SLF4J.

@pzygielo pzygielo requested a review from michael-o May 30, 2020 13:43
@pzygielo
Copy link
Contributor Author

@michael-o thanks for checking.
Formatting applied, usage of String.format removed.

@asfgit asfgit closed this in 02d0b28 May 30, 2020
@pzygielo pzygielo deleted the mdep-680 branch May 30, 2020 15:38
pmoerenhout pushed a commit to pmoerenhout/maven-dependency-plugin that referenced this pull request Jun 18, 2020
@zzgzy
Copy link

zzgzy commented Jun 23, 2020

Is this change merged in?

@pzygielo
Copy link
Contributor Author

@zzgzy It was merged, but new plugin version (3.1.3) wasn't released yet.

cosmin pushed a commit to cosmin/maven-dependency-plugin that referenced this pull request Nov 24, 2020
@jira-importer
Copy link

Resolve #1203

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants