Skip to content

Commit db2bb19

Browse files
wkl3nksschuberth
authored andcommitted
fix(Maven): Handle automatically wrapped p2 dependencies
The dependency resolution logic failed to process dependencies that were automatically converted from Maven to p2 by Tycho. When using the `missingManifest="generate"` feature, Tycho creates a p2 bundle for a Maven artifact that lacks an OSGi manifest. This process involves adding a "wrapped." prefix to the artifact's ID. Update the resolution mechanism to detect and strip this "wrapped." prefix. This allows the Tycho package manager to correctly map the generated p2 dependency back to its original Maven coordinates, fixing the resolution failure. Fixes #11174. Signed-off-by: klw1imb <[email protected]>
1 parent 65dbe30 commit db2bb19

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

plugins/package-managers/maven/src/main/kotlin/tycho/TargetHandler.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,18 @@ internal class TargetHandler(
117117
* to find the original Maven coordinates for affected artifacts. They are needed to retrieve the correct metadata.
118118
* Result is *null* if no matching Maven dependency is found.
119119
*/
120-
fun mapToMavenDependency(tychoArtifact: Artifact): Artifact? =
121-
mavenDependencies[tychoArtifact.artifactId]?.also { dep ->
120+
fun mapToMavenDependency(tychoArtifact: Artifact): Artifact? {
121+
// Strip the "wrapped." prefix that might have been added by Tycho's automatic bundle wrapping mechanism
122+
// (missingManifest="generate") to find the original Maven artifact.
123+
val unwrappedArtifactId = tychoArtifact.artifactId.removePrefix("wrapped.")
124+
125+
return mavenDependencies[unwrappedArtifactId]?.also { dep ->
122126
logger.info {
123127
"Mapping Tycho artifact '${tychoArtifact.groupId}:${tychoArtifact.artifactId}' to Maven " +
124128
"dependency '${dep.groupId}:${dep.artifactId}'."
125129
}
126130
}
131+
}
127132
}
128133

129134
/**

plugins/package-managers/maven/src/test/assets/tycho.target

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
<version>2.15.2</version>
4444
<type>jar</type>
4545
</dependency>
46+
47+
<!-- This dependency has a missing manifest in its jar, so Tycho will generate one and wrap a
48+
p2 bundle around it. -->
49+
<dependency>
50+
<groupId>org.apache.xmlbeans</groupId>
51+
<artifactId>xmlbeans</artifactId>
52+
<version>3.1.0</version>
53+
<type>jar</type>
54+
</dependency>
4655
</dependencies>
4756
</location>
4857
</locations>

0 commit comments

Comments
 (0)