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

Inject content of settings.xml into the artifact resolution. #1092

Merged
merged 1 commit into from Sep 16, 2022
Merged

Inject content of settings.xml into the artifact resolution. #1092

merged 1 commit into from Sep 16, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jun 29, 2022

When downloading Maven artifacts from e.g. a private repository, Tycho
needs to authenticate itself as a valid user, using the credentials
provided in the settings.xml file.

Otherwise the request most likely fails with a 401 - Unauthorized.

As context: We deploy some of our artifacts to a local Nexus. Currently, anonymous access is enabled, hence why Tycho can download them as dependencies for our product without problem. But at some point, we want to get rid of it, due to security requirements.

Tycho already supports authenticated access for p2 repositories, but for Maven repositories, the content of the settings.xml file is ignored.

@ghost
Copy link
Author

ghost commented Jun 29, 2022

The pull request is currently at a state where Tycho successfully downloads the jars, but then fails when downloading the corresponding pom during the compilation phase. Does anyone have an idea what I'm missing?

Stacktrace

[ERROR] Failed to execute goal on project de.dsa.prodis.bbprotection: Could not resolve dependencies for project de.dsa.eal:de.dsa.prodis.bbprotection:eclipse-plugin:0.0.1-SNAPSHOT: Failed to collect dependencies at de.dsa.eal.common:de.dsa.base.factories:jar:1.3.0.20220504: Failed to read artifact descriptor for de.dsa.eal.common:de.dsa.base.factories:jar:1.3.0.20220504: Could not transfer artifact de.dsa.eal.common:de.dsa.base.factories:pom:1.3.0.20220504 from/to nexus-m2.repository (https://nexusext.app.corp.dsa.de/repository/sfp-alp-eal-group-releases/): authentication failed for https://nexusext.app.corp.dsa.de/repository/sfp-alp-eal-group-releases/de/dsa/eal/common/de.dsa.base.factories/1.3.0.20220504/de.dsa.base.factories-1.3.0.20220504.pom, status: 401 Unauthorized -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project de.dsa.prodis.bbprotection: Could not resolve dependencies for project de.dsa.eal:de.dsa.prodis.bbprotection:eclipse-plugin:0.0.1-SNAPSHOT: Failed to collect dependencies at de.dsa.eal.common:de.dsa.base.factories:jar:1.3.0.20220504
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:269)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:339)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:293)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project de.dsa.eal:de.dsa.prodis.bbprotection:eclipse-plugin:0.0.1-SNAPSHOT: Failed to collect dependencies at de.dsa.eal.common:de.dsa.base.factories:jar:1.3.0.20220504
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (DefaultProjectDependenciesResolver.java:179)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:339)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:293)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect dependencies at de.dsa.eal.common:de.dsa.base.factories:jar:1.3.0.20220504
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies (DefaultDependencyCollector.java:288)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies (DefaultRepositorySystem.java:284)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (DefaultProjectDependenciesResolver.java:170)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:339)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:293)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for de.dsa.eal.common:de.dsa.base.factories:jar:1.3.0.20220504
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:255)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:171)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.resolveCachedArtifactDescriptor (DefaultDependencyCollector.java:538)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.getArtifactDescriptorResult (DefaultDependencyCollector.java:523)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency (DefaultDependencyCollector.java:410)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency (DefaultDependencyCollector.java:362)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.process (DefaultDependencyCollector.java:349)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies (DefaultDependencyCollector.java:254)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies (DefaultRepositorySystem.java:284)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (DefaultProjectDependenciesResolver.java:170)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:339)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:293)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact de.dsa.eal.common:de.dsa.base.factories:pom:1.3.0.20220504 from/to nexus-m2.repository (https://nexusext.app.corp.dsa.de/repository/sfp-alp-eal-group-releases/): authentication failed for https://nexusext.app.corp.dsa.de/repository/sfp-alp-eal-group-releases/de/dsa/eal/common/de.dsa.base.factories/1.3.0.20220504/de.dsa.base.factories-1.3.0.20220504.pom, status: 401 Unauthorized
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:425)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:207)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:240)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:171)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.resolveCachedArtifactDescriptor (DefaultDependencyCollector.java:538)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.getArtifactDescriptorResult (DefaultDependencyCollector.java:523)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency (DefaultDependencyCollector.java:410)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency (DefaultDependencyCollector.java:362)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.process (DefaultDependencyCollector.java:349)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies (DefaultDependencyCollector.java:254)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies (DefaultRepositorySystem.java:284)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (DefaultProjectDependenciesResolver.java:170)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:339)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:293)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact de.dsa.eal.common:de.dsa.base.factories:pom:1.3.0.20220504 from/to nexus-m2.repository (https://nexusext.app.corp.dsa.de/repository/sfp-alp-eal-group-releases/): authentication failed for https://nexusext.app.corp.dsa.de/repository/sfp-alp-eal-group-releases/de/dsa/eal/common/de.dsa.base.factories/1.3.0.20220504/de.dsa.base.factories-1.3.0.20220504.pom, status: 401 Unauthorized    at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed (ArtifactTransportListener.java:52)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:369)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute (BasicRepositoryConnector.java:628)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get (BasicRepositoryConnector.java:262)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads (DefaultArtifactResolver.java:514)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:402)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:207)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:240)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:171)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.resolveCachedArtifactDescriptor (DefaultDependencyCollector.java:538)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.getArtifactDescriptorResult (DefaultDependencyCollector.java:523)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency (DefaultDependencyCollector.java:410)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency (DefaultDependencyCollector.java:362)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.process (DefaultDependencyCollector.java:349)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies (DefaultDependencyCollector.java:254)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies (DefaultRepositorySystem.java:284)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (DefaultProjectDependenciesResolver.java:170)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:339)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:293)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.wagon.authorization.AuthorizationException: authentication failed for https://nexusext.app.corp.dsa.de/repository/sfp-alp-eal-group-releases/de/dsa/eal/common/de.dsa.base.factories/1.3.0.20220504/de.dsa.base.factories-1.3.0.20220504.pom, status: 401 Unauthorized
    at org.apache.maven.wagon.providers.http.wagon.shared.AbstractHttpClientWagon.resourceExists (AbstractHttpClientWagon.java:898)
    at org.apache.maven.wagon.providers.http.wagon.shared.AbstractHttpClientWagon.resourceExists (AbstractHttpClientWagon.java:869)
    at org.eclipse.aether.transport.wagon.WagonTransporter$PeekTaskRunner.run (WagonTransporter.java:508)
    at org.eclipse.aether.transport.wagon.WagonTransporter.execute (WagonTransporter.java:430)
    at org.eclipse.aether.transport.wagon.WagonTransporter.peek (WagonTransporter.java:401)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PeekTaskRunner.runTask (BasicRepositoryConnector.java:390)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:364)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute (BasicRepositoryConnector.java:628)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get (BasicRepositoryConnector.java:262)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads (DefaultArtifactResolver.java:514)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:402)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:207)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:240)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:171)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.resolveCachedArtifactDescriptor (DefaultDependencyCollector.java:538)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.getArtifactDescriptorResult (DefaultDependencyCollector.java:523)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency (DefaultDependencyCollector.java:410)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency (DefaultDependencyCollector.java:362)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.process (DefaultDependencyCollector.java:349)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies (DefaultDependencyCollector.java:254)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies (DefaultRepositorySystem.java:284)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (DefaultProjectDependenciesResolver.java:170)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:339)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:293)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

@github-actions

This comment was marked as outdated.

@laeubi
Copy link
Member

laeubi commented Jul 2, 2022

@pzi-dsa this looks very interesting. Do you think you can add an integration test for this? There are already some for maven and updatesite authentication that might could be used as a basis?

@ghost
Copy link
Author

ghost commented Jul 5, 2022

I've tried setting up an integration test similar to PasswordProtectedP2RepositoryTest. However it seems mocking a m2 repository is a little bit more complicated than a p2 repository.
I'm also at a loss at how to proceed with the actual implementation. Authentication works when adding the repository directly to the pom, but fails if it is added to the location of the target platform.

So clearly there is something native Maven does, that Tycho doesn't. I just can't figure out what... :/

Given that it works in m2e, I also looked at how it's done there. But there everything is managed by the IMaven interface, which also solves this via the call of injectAuthentication(...).

@laeubi
Copy link
Member

laeubi commented Jul 5, 2022

Authentication works when adding the repository directly to the pom, but fails if it is added to the location of the target platform.

I must confess that I assumed there is nothing to do specially as we use the maven resolver system. The only think I can think of is that somehow the ID is messed up and maven uses the ID to find the authentication...

@laeubi
Copy link
Member

laeubi commented Jul 6, 2022

@pzi-dsa if there is a public available example I can also try to take a look, but I have no password-protected setup at hand here to test...

@ghost
Copy link
Author

ghost commented Jul 6, 2022

I think I managed to get the integration test running. It turned out the GAV in the target platform didn't match the artifact in the repository.

On the master, I get the following entry in my .m2 repository:

#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Wed Jul 06 11:03:48 CEST 2022
@default-central-https\://repo.maven.apache.org/maven2/.lastUpdated=1657098228437
@default-test-server-http\://localhost\:60326/foo/.lastUpdated=1657098228528
https\://repo.maven.apache.org/maven2/.error=Could not transfer artifact test\:jakarta.inject-api\:jar\:1.0 from/to central (https\://repo.maven.apache.org/maven2)\: transfer failed for https\://repo.maven.apache.org/maven2/test/jakarta.inject-api/1.0/jakarta.inject-api-1.0.jar
http\://localhost\:60326/foo/.error=Could not transfer artifact test\:jakarta.inject-api\:jar\:1.0 from/to test-server (http\://localhost\:60326/foo)\: authentication failed for http\://localhost\:60326/foo/test/jakarta.inject-api/1.0/jakarta.inject-api-1.0.jar, status\: 401 Unauthorized

And on my branch, the following:

#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Wed Jul 06 11:08:36 CEST 2022
@default-central-https\://repo.maven.apache.org/maven2/.lastUpdated=1657098516492
https\://repo.maven.apache.org/maven2/.error=Could not transfer artifact test\:jakarta.inject-api\:jar\:1.0 from/to central (https\://repo.maven.apache.org/maven2)\: transfer failed for https\://repo.maven.apache.org/maven2/test/jakarta.inject-api/1.0/jakarta.inject-api-1.0.jar
http\://localhost\:64875/foo/.lastUpdated=1657098516637

In the second case, the jar is also successfully stored in my local repository. Which is exactly what I was hoping for.
However, I have yet to reproduce the second error. i.e. I still need to understand what's causing Tycho to download the pom file.

@github-actions
Copy link

github-actions bot commented Jul 6, 2022

Test Results

326 files  326 suites   2h 26m 2s ⏱️
291 tests 285 ✔️ 4 💤 0  2 🔥
582 runs  571 ✔️ 9 💤 0  2 🔥

For more details on these errors, see this check.

Results for commit dc5a5e8.

♻️ This comment has been updated with latest results.

@laeubi
Copy link
Member

laeubi commented Jul 6, 2022

Tycho injects the Maven artifacts into the model, and then maven tries to download them. In general, they should already be available locally then, but for the case of password-protected mirrors there might be a flaw.

There is also some ongoing work to improve this. Can you explain what "It turned out the GAV in the target platform didn't match the artifact in the repository." mean here?

@ghost
Copy link
Author

ghost commented Jul 6, 2022

Can you explain what "It turned out the GAV in the target platform didn't match the artifact in the repository." mean here?

The mock repository I created for the test only contains a single artifact, test:jakarta.inject-api:1.0. But in my target file, I was referencing test:jakarta.inject:1.0.
So the test failed because it couldn't resolve the target platform, which I mistook as having misconfigured the Maven repository.

It has nothing to do with the problem at hand, just a mistake on my side.

@ghost
Copy link
Author

ghost commented Jul 6, 2022

I think I managed to adapt the test case in such a way that it reproduces the stacktrace from my second comment. They are not identical, but both lead to the same cause, the inability to download the pom file from the local Maven repository, as shown in the lastUpdated file:

#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Wed Jul 06 15:01:47 CEST 2022
@default-central-https\://repo.maven.apache.org/maven2/.lastUpdated=1657112507084
https\://repo.maven.apache.org/maven2/.error=Could not transfer artifact test\:bundle\:pom\:1.0.0 from/to central (https\://repo.maven.apache.org/maven2)\: transfer failed for https\://repo.maven.apache.org/maven2/test/bundle/1.0.0/bundle-1.0.0.pom
http\://localhost\:54796/foo/.error=Could not transfer artifact test\:bundle\:pom\:1.0.0 from/to test-server (http\://localhost\:54796/foo)\: authentication failed for http\://localhost\:54796/foo/test/bundle/1.0.0/bundle-1.0.0.pom, status\: 401 Unauthorized
@default-test-server-http\://localhost\:54796/foo/.lastUpdated=1657112507089

If I set this draft to "Ready for review", it should start the test suite, right? Hopefully it will then fail with the same error.

@laeubi laeubi marked this pull request as ready for review July 6, 2022 14:22
@laeubi
Copy link
Member

laeubi commented Jul 7, 2022

@ghost
Copy link
Author

ghost commented Jul 7, 2022

@laeubi I think that's exactly it!

@laeubi
Copy link
Member

laeubi commented Jul 7, 2022

Alright, I think your previous code changes are not related to this failure and it would wonder me if they make anything better as we should inherit the maven settings but the maven resolution itself has a problem here, so if you like the starting point for debugging should be org.eclipse.tycho.core.maven.MavenDependencyInjector.injectMavenDependencies(....) where we try to inject the repositories from the target into the model here:

https://github.com/eclipse/tycho/blob/bb190b4f39df1a55012b89f45ee9adba31a9f70a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/MavenDependencyInjector.java#L77-L94

this should be the first place to check if something went wrong here (e.g. wrong/missing ids, no repositories injected at all / ...) and also a breakpoint at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:240) to check if maybe maven itself misses something here we need to also fill in the above method.

@laeubi laeubi marked this pull request as draft September 14, 2022 08:08
@ghost
Copy link
Author

ghost commented Sep 14, 2022

I finally got some time to revisit this pull request, and I think your suspicion was spot-on, @laeubi

To quickly explain what's going on:
Tycho creates a bare-bones object for all Maven repositories which have been specified in the target platform definition, containing only the corresponding id and url. So it lacks the user credentials, mirrors,... Effectively anything contributed via the settings.xml.

Because those repositories are injected back into the Maven model, due to Issue #697, it then caused the seemingly unrelated stacktrace which had me stuck for quite a while.

Meaning I "only" had to inject settings.xml into those repositories, whenever they are created.

Thank you a lot for your help :)

@ghost ghost marked this pull request as ready for review September 14, 2022 10:06
@ghost
Copy link
Author

ghost commented Sep 14, 2022

java.lang.SecurityException: class "org.eclipse.core.runtime.Plugin"'s signer information does not match signer information of other classes in the same package

The error seems more like an Eclipse issue and unrelated to my changes.

Failed to bind to 0.0.0.0/0.0.0.0:58444

And this warning only happens on Windows... Likely a problem when setting up the mock HTTP server, would be my guess. Though I don't see why this fails for the m2 test but not the p2 test. :-|

For artifact repositories which have been specified in the target
platform definition, Tycho creates a minimal instance, containing only
an id and url, which is then injected back into the Maven model.

In order to support e.g. authenticating against a private repository, it
is necessary to also inject the user credentials, provided via the local
settings.xml, into this instance. Otherwise accessing the referenced
artifacts fails with a 401 - Unauthorized.
@laeubi laeubi added this to the 3.0 milestone Sep 15, 2022
@laeubi
Copy link
Member

laeubi commented Sep 15, 2022

Github action failures are unrelated.

@laeubi laeubi merged commit 952fbb3 into eclipse-tycho:master Sep 16, 2022
@laeubi
Copy link
Member

laeubi commented Sep 16, 2022

@pzi-dsa thanks for the fix and for the test-case! Lets see if this improves the situation for you 👍

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.

2 participants