Skip to content

PDE - MavenDependencies with "test" scope fails when declared in the target file since 2025-03 #1976

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

Open
opcoach opened this issue Apr 10, 2025 · 4 comments

Comments

@opcoach
Copy link

opcoach commented Apr 10, 2025

I use a maven block with this scope in my target file (see below), and since Eclipse 2025-03, the target fails to load:

includeDependencyScopes="compile,test"

If I remove the "test" scope, the target is loaded.

Is there a problem with maven test scope ?

 <location includeDependencyDepth="infinite" includeDependencyScopes="compile,test" includeSource="true" missingManifest="generate" type="Maven" label="MavenDependencies"> 
      <dependencies>
        <dependency>
          <groupId>com.clearspring.analytics</groupId>
          <artifactId>stream</artifactId>
          <version>2.9.6</version>
          <type>jar</type>
        </dependency>
        <dependency>
          <groupId>javax.xml.rpc</groupId>
          <artifactId>javax.xml.rpc-api</artifactId>
          <version>1.1.2</version>
          <type>jar</type>
        </dependency>
        <dependency>
          <groupId>org.apache.avro</groupId>
          <artifactId>avro</artifactId>
          <version>1.12.0</version>
          <type>jar</type>
        </dependency>
      </dependencies>
    </location>

Here is the message with "test" :

Image

And the message without test :

Image

@laeubi
Copy link
Member

laeubi commented Apr 14, 2025

If you open the target file you should see an more detailed error.

In any case we have a test-suite for maven targets here:
https://github.com/eclipse-m2e/m2e-core/blob/main/org.eclipse.m2e.pde.target.tests/src/org/eclipse/m2e/pde/target/tests/OSGiMetadataGenerationTest.java

so the best is to add your example there (and maybe make it more minimal) so we can isolate/fix the problem and it do not occur again.

@alfonsodelavega
Copy link

We have also seen these errors in the Epsilon target platform after updating to 2025-03. Removing the test scope indeed makes the dependencies load and the projects compile.

The following "Resolving dependencies failed" error appears in the error log after reloading the TP:

org.eclipse.aether.resolution.ArtifactResolutionException: The following artifacts could not be resolved: stax:stax-ri:jar:1.0 (absent): stax:stax-ri:jar:1.0 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:473)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:261)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:243)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:278)
	at org.eclipse.m2e.pde.target.shared.MavenDependencyCollector.readArtifactDescriptor(MavenDependencyCollector.java:142)
	at org.eclipse.m2e.pde.target.shared.MavenDependencyCollector.collect(MavenDependencyCollector.java:112)
	at org.eclipse.m2e.pde.target.MavenTargetLocation.lambda$14(MavenTargetLocation.java:295)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:458)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:339)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:278)
	at org.eclipse.m2e.pde.target.MavenTargetLocation.resolveDependency(MavenTargetLocation.java:264)
	at org.eclipse.m2e.pde.target.MavenTargetLocation.resolveArtifacts(MavenTargetLocation.java:176)
	at org.eclipse.m2e.pde.target.MavenTargetLocation.resolveBundles(MavenTargetLocation.java:163)
	at org.eclipse.pde.internal.core.target.AbstractBundleContainer.resolve(AbstractBundleContainer.java:97)
	at org.eclipse.pde.internal.core.target.TargetDefinition.resolve(TargetDefinition.java:379)
	at org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor$TargetChangedListener$1.run(TargetEditor.java:684)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: stax:stax-ri:jar:1.0 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced
	at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:225)
	at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:201)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:586)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:525)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:449)
	... 16 more

which is strange, because stax-ri seems like an old project that I think is not present in Maven Central.

I have reduced our target platform to the following, which also suffers from the issue:

<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="Epsilon Target Platform" sequenceNumber="1747037548">
  <locations>
    <location includeDependencyDepth="infinite" includeDependencyScopes="compile,test,runtime" includeSource="true" missingManifest="generate" type="Maven" label="MavenDependencies">
      <dependencies>
        <dependency>
          <groupId>org.apache.poi</groupId>
          <artifactId>poi</artifactId>
          <version>4.1.2</version>
          <type>jar</type>
        </dependency>
        <dependency>
          <groupId>org.apache.poi</groupId>
          <artifactId>poi-ooxml</artifactId>
          <version>4.1.2</version>
          <type>jar</type>
        </dependency>
      </dependencies>
    </location>
  </locations>
  <targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
</target>

That TP was generated with the TP dsl:

target "Epsilon Target Platform" environment JavaSE-17 with configurePhase requirements source

maven MavenDependencies scope=compile,test,runtime dependencyDepth=infinite missingManifest=generate includeSources {
	dependency {
        groupId="org.apache.poi"
        artifactId="poi"
        version="4.1.2"
    }
    dependency {
        groupId="org.apache.poi"
        artifactId="poi-ooxml"
        version="4.1.2"
    }
}

I can create a PR to the test file you mentioned.

Thanks,
Alfonso

@laeubi
Copy link
Member

laeubi commented May 12, 2025

I can create a PR to the test file you mentioned.

Yes please do so sadly currently m2e suffers from the Eclipse Infor issues, so maybe the PR is failing but we can later integrate it.

@alfonsodelavega
Copy link

Added in #1988

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

No branches or pull requests

3 participants