Skip to content

Conversation

@alfonsodelavega
Copy link

@alfonsodelavega alfonsodelavega commented May 12, 2025

Related to #1976, this PR adds a test that fails when using the test scope when loading a Maven dependency from a target platform.

I was not able to build and test the m2e-core repository locally, I just copied the structure of the other test methods in the suite.

@github-actions
Copy link

Test Results

0 files   -   324  0 suites   - 324   0s ⏱️ - 48m 23s
0 tests  -   686  0 ✅  -   664  0 💤  - 20  0 ❌  - 1 
0 runs   - 2 058  0 ✅  - 1 996  0 💤  - 60  0 ❌  - 1 

Results for commit d216644. ± Comparison against base commit c23bb6a.

@laeubi
Copy link
Member

laeubi commented May 13, 2025

The problem is that somewhere in the chain this dependency is referenced:

https://mvnrepository.com/artifact/stax/stax-ri

and it is actually not on maven-central. I'm not completely sure if it is maybe "as expected" that this fails or if we should handle it more gracefully...

One thing that I planned was to not fail the complete resolution but still show it as an error in the tree so people can get aware of it but that requires some more work.

@alfonsodelavega
Copy link
Author

What is very strange is that when removing the test scope (or returning to 2024-12) then the issue does not manifest.

The missing library error changes when bumping the version of the dependency:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="Epsilon Target Platform" sequenceNumber="1747210159">
  <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>5.4.1</version>
          <type>jar</type>
        </dependency>
        <dependency>
          <groupId>org.apache.poi</groupId>
          <artifactId>poi-ooxml</artifactId>
          <version>5.4.1</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>

Now it's guava-tests the missing one, but this one actually IS in Maven central, but it is asking for version 32, when the highest one in Central is 23.3 (from 2017)

org.eclipse.aether.resolution.ArtifactResolutionException: The following artifacts could not be resolved: com.google.guava:guava-tests:jar:tests:32.0.0-jre (absent): com.google.guava:guava-tests:jar:tests:32.0.0-jre 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.cbi.targetplatform.ui.handler.PDEIntegration.trySetTargetPlatform(PDEIntegration.java:90)
	at org.eclipse.cbi.targetplatform.ui.handler.PDEIntegration.setTargetPlatform(PDEIntegration.java:77)
	at org.eclipse.cbi.targetplatform.ui.handler.ConvertTargetPlatformJob.run(ConvertTargetPlatformJob.java:92)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: com.google.guava:guava-tests:jar:tests:32.0.0-jre 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)
	... 18 more

@laeubi
Copy link
Member

laeubi commented May 14, 2025

What is very strange is that when removing the test scope (or returning to 2024-12) then the issue does not manifest.

It seems test scope is pulling in some garbage. As previously we have missed some items these now start creating problems.

May I ask why you need test scoped dependencies from third party lib here? It might be better to explicitly include whats missing instead of pulling in the whole whack of stuff.

@alfonsodelavega
Copy link
Author

I've just checked that our tests (both from CLI and from Eclipse) seem to run fine without the test scope in the Maven dependencies, so maybe we're not testing code that depends on these / our tests do not use the test scope?

Honestly, I do not know in which contexts the test or runtime scopes are used.

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