Skip to content

Commit 2f77a9d

Browse files
authored
Merge pull request #411 from laeubi/isse_331
Fix #331 Support pom dependecies in maven targets
2 parents 7fc1694 + 288d802 commit 2f77a9d

File tree

14 files changed

+234
-13
lines changed

14 files changed

+234
-13
lines changed

tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenDependenciesResolver.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ public interface MavenDependenciesResolver {
3838
* @return
3939
*/
4040
default Collection<? /* IArtifactFacade */> resolve(String groupId, String artifactId, String version,
41-
String packaging, String classifier, String dependencyScope,
41+
String packaging, String classifier, String dependencyScope, boolean resolveTransitive,
4242
Collection<MavenArtifactRepositoryReference> additionalRepositories) {
43-
return resolve(groupId, artifactId, version, packaging, classifier, dependencyScope, additionalRepositories,
44-
null);
43+
return resolve(groupId, artifactId, version, packaging, classifier, dependencyScope, resolveTransitive,
44+
additionalRepositories, null);
4545
}
4646

4747
Collection<? /* IArtifactFacade */> resolve(String groupId, String artifactId, String version, String packaging,
48-
String classifier, String dependencyScope,
48+
String classifier, String dependencyScope, boolean resolveTransitive,
4949
Collection<MavenArtifactRepositoryReference> additionalRepositories,
5050
Object/* MavenSession */ session);
5151

tycho-bundles/org.eclipse.tycho.p2.resolver.impl/META-INF/MANIFEST.MF

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Export-Package: org.eclipse.tycho.p2.impl;x-friends:="org.eclipse.tycho.p2.impl.
3232
org.eclipse.tycho.p2.target,
3333
org.eclipse.tycho.p2.target.ee;x-friends:="org.eclipse.tycho.p2.tools.impl",
3434
org.eclipse.tycho.p2.util.resolution
35-
Import-Package: org.eclipse.tycho,
35+
Import-Package: org.apache.commons.io;version="2.8.0",
36+
org.eclipse.tycho,
3637
org.eclipse.tycho.artifacts,
3738
org.eclipse.tycho.core.ee.shared,
3839
org.eclipse.tycho.core.resolver.shared,

tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/resolver/MavenTargetDefinitionContent.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.jar.Manifest;
3333
import java.util.zip.ZipEntry;
3434

35+
import org.apache.commons.io.FilenameUtils;
3536
import org.eclipse.equinox.p2.core.IProvisioningAgent;
3637
import org.eclipse.equinox.p2.metadata.IArtifactKey;
3738
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -87,18 +88,28 @@ public MavenTargetDefinitionContent(MavenGAVLocation location, MavenDependencies
8788
logger.info((reference.isEmpty() ? "default instructions" : reference) + " = " + properties);
8889
}
8990
for (MavenDependency mavenDependency : location.getRoots()) {
91+
boolean isPom = "pom".equalsIgnoreCase(mavenDependency.getArtifactType());
9092
Collection<?> resolve = mavenDependenciesResolver.resolve(mavenDependency.getGroupId(),
9193
mavenDependency.getArtifactId(), mavenDependency.getVersion(),
9294
mavenDependency.getArtifactType(), mavenDependency.getClassifier(),
93-
location.getIncludeDependencyScope(), location.getRepositoryReferences());
95+
location.getIncludeDependencyScope(), isPom, location.getRepositoryReferences());
9496

9597
Iterator<IArtifactFacade> resolvedArtifacts = resolve.stream().filter(IArtifactFacade.class::isInstance)
9698
.map(IArtifactFacade.class::cast).iterator();
9799
Properties defaultProperties = WrappedArtifact.createPropertiesForPrefix("wrapped");
98100
while (resolvedArtifacts.hasNext()) {
99101
IArtifactFacade mavenArtifact = resolvedArtifacts.next();
100102
if (mavenDependency.isIgnored(mavenArtifact)) {
101-
logger.debug("Skipp ignored " + mavenArtifact + "...");
103+
logger.debug("Skip ignored " + mavenArtifact + "...");
104+
continue;
105+
}
106+
if ("pom".equalsIgnoreCase(mavenArtifact.getPackagingType())) {
107+
logger.debug("Skip pom artifact " + mavenArtifact + "...");
108+
continue;
109+
}
110+
String fileName = mavenArtifact.getLocation().getName();
111+
if (!"jar".equalsIgnoreCase(FilenameUtils.getExtension(fileName))) {
112+
logger.info("Skip non-jar artifact ... (" + fileName + ")");
102113
continue;
103114
}
104115
logger.debug("Resolved " + mavenArtifact + "...");
@@ -182,7 +193,7 @@ public MavenTargetDefinitionContent(MavenGAVLocation location, MavenDependencies
182193
|| (sourceMode == IncludeSourceMode.honor && location.includeSource())) {
183194
Collection<?> sourceArtifacts = mavenDependenciesResolver.resolve(mavenArtifact.getGroupId(),
184195
mavenArtifact.getArtifactId(), mavenArtifact.getVersion(),
185-
mavenArtifact.getPackagingType(), "sources", null, Collections.emptyList());
196+
mavenArtifact.getPackagingType(), "sources", null, false, Collections.emptyList());
186197
Iterator<IArtifactFacade> sources = sourceArtifacts.stream()
187198
.filter(IArtifactFacade.class::isInstance).map(IArtifactFacade.class::cast).iterator();
188199
while (sources.hasNext()) {

tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenDependenciesResolverConfigurer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public class MavenDependenciesResolverConfigurer extends EquinoxLifecycleListene
5050

5151
@Override
5252
public Collection<?> resolve(String groupId, String artifactId, String version, String packaging, String classifier,
53-
String dependencyScope, Collection<MavenArtifactRepositoryReference> additionalRepositories,
54-
Object session) {
53+
String dependencyScope, boolean resolveTransitive,
54+
Collection<MavenArtifactRepositoryReference> additionalRepositories, Object session) {
5555
Artifact artifact;
5656
if (classifier != null && !classifier.isEmpty()) {
5757
artifact = repositorySystem.createArtifactWithClassifier(groupId, artifactId, version, packaging,
@@ -65,7 +65,7 @@ public Collection<?> resolve(String groupId, String artifactId, String version,
6565
MavenSession mavenSession = getMavenSession(session);
6666
request.setOffline(mavenSession.isOffline());
6767
request.setLocalRepository(mavenSession.getLocalRepository());
68-
request.setResolveTransitively(dependencyScope != null && !dependencyScope.isEmpty());
68+
request.setResolveTransitively(resolveTransitive || (dependencyScope != null && !dependencyScope.isEmpty()));
6969
if (additionalRepositories != null && additionalRepositories.size() > 0) {
7070
List<ArtifactRepository> repositories = new ArrayList<>(
7171
mavenSession.getCurrentProject().getRemoteArtifactRepositories());

tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenProtocolHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ public void connect() throws IOException {
109109
String type = coordinates.length > 3 ? coordinates[3] : "jar";
110110
String classifier = coordinates.length > 4 ? coordinates[4] : null;
111111
Collection<?> resolve = resolver.resolve(coordinates[0], coordinates[1], coordinates[2], type,
112-
classifier, null, Collections.emptyList(), session);
112+
classifier, null, false, Collections.emptyList(), session);
113113
if (resolve.isEmpty()) {
114114
throw new IOException("artifact " + Arrays.toString(coordinates)
115-
+ " could not be downloaded from any of the available repositories");
115+
+ " could not be retrieved from any of the available repositories");
116116
}
117117
if (resolve.size() > 1) {
118118
throw new IOException(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- - Copyright (c) 2015, 2020 SAP SE and others. - All rights reserved. This
3+
program and the accompanying materials - are made available under the terms
4+
of the Eclipse Public License v1.0 - which accompanies this distribution,
5+
and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors:
6+
- SAP SE - initial API and implementation -->
7+
8+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<groupId>org.eclipse.tycho.itests</groupId>
13+
<artifactId>issue-331-parent</artifactId>
14+
<version>0.0.1-SNAPSHOT</version>
15+
<packaging>pom</packaging>
16+
17+
<modules>
18+
<module>test.bundle</module>
19+
<module>test.feature</module>
20+
</modules>
21+
22+
<build>
23+
<plugins>
24+
<plugin>
25+
<groupId>org.eclipse.tycho</groupId>
26+
<artifactId>tycho-maven-plugin</artifactId>
27+
<version>${tycho-version}</version>
28+
<extensions>true</extensions>
29+
</plugin>
30+
<plugin>
31+
<groupId>org.eclipse.tycho</groupId>
32+
<artifactId>target-platform-configuration</artifactId>
33+
<version>${tycho-version}</version>
34+
<configuration>
35+
36+
<target>
37+
<file>../test.target</file>
38+
</target>
39+
</configuration>
40+
</plugin>
41+
</plugins>
42+
</build>
43+
44+
45+
46+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-Name: Bundle
4+
Bundle-SymbolicName: test.bundle
5+
Bundle-Version: 0.0.1.qualifier
6+
Automatic-Module-Name: test.bundle
7+
Bundle-RequiredExecutionEnvironment: JavaSE-11
8+
Require-Bundle: jakarta.xml.bind-api;bundle-version="[3.0.1,4.0.0)"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source.. = src/
2+
output.. = bin/
3+
bin.includes = META-INF/,\
4+
.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2012 SAP AG All rights reserved. This program
4+
and the accompanying materials are made available under the terms of
5+
the Eclipse Public License v1.0 which accompanies this distribution,
6+
and is available at http://www.eclipse.org/legal/epl-v10.html
7+
-->
8+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>test.bundle</artifactId>
13+
<packaging>eclipse-plugin</packaging>
14+
15+
<parent>
16+
<groupId>org.eclipse.tycho.itests</groupId>
17+
<artifactId>issue-331-parent</artifactId>
18+
<version>0.0.1-SNAPSHOT</version>
19+
</parent>
20+
21+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 Christoph Läubrich and others.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Christoph Läubrich - initial API and implementation
12+
*******************************************************************************/
13+
package test.bundle;
14+
15+
import jakarta.xml.bind.annotation.XmlAttribute;
16+
import jakarta.xml.bind.annotation.XmlElement;
17+
import jakarta.xml.bind.annotation.XmlRootElement;
18+
19+
@XmlRootElement
20+
public class TestClass {
21+
22+
@XmlElement
23+
private String element;
24+
25+
@XmlAttribute
26+
private String attribute;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin.includes = feature.xml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<feature
3+
id="test.feature"
4+
label="Feature"
5+
version="0.0.1.qualifier">
6+
7+
<description url="http://www.example.com/description">
8+
[Enter Feature Description here.]
9+
</description>
10+
11+
<copyright url="http://www.example.com/copyright">
12+
[Enter Copyright Description here.]
13+
</copyright>
14+
15+
<license url="http://www.example.com/license">
16+
[Enter License Description here.]
17+
</license>
18+
19+
<plugin
20+
id="com.sun.xml.ws.jaxws-rt"
21+
download-size="0"
22+
install-size="0"
23+
version="0.0.0"
24+
unpack="false"/>
25+
26+
<plugin
27+
id="jakarta.jws-api"
28+
download-size="0"
29+
install-size="0"
30+
version="0.0.0"
31+
unpack="false"/>
32+
33+
<plugin
34+
id="jakarta.xml.bind-api"
35+
download-size="0"
36+
install-size="0"
37+
version="0.0.0"
38+
unpack="false"/>
39+
40+
<plugin
41+
id="jakarta.xml.soap-api"
42+
download-size="0"
43+
install-size="0"
44+
version="0.0.0"
45+
unpack="false"/>
46+
47+
<plugin
48+
id="jakarta.xml.ws-api"
49+
download-size="0"
50+
install-size="0"
51+
version="0.0.0"
52+
unpack="false"/>
53+
54+
<plugin
55+
id="com.sun.activation.jakarta.activation"
56+
download-size="0"
57+
install-size="0"
58+
version="0.0.0"
59+
unpack="false"/>
60+
61+
</feature>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2012 SAP AG All rights reserved. This program
4+
and the accompanying materials are made available under the terms of
5+
the Eclipse Public License v1.0 which accompanies this distribution,
6+
and is available at http://www.eclipse.org/legal/epl-v10.html
7+
-->
8+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>test.feature</artifactId>
13+
<packaging>eclipse-feature</packaging>
14+
15+
<parent>
16+
<groupId>org.eclipse.tycho.itests</groupId>
17+
<artifactId>issue-331-parent</artifactId>
18+
<version>0.0.1-SNAPSHOT</version>
19+
</parent>
20+
21+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?pde version="3.8"?>
3+
<target name="test">
4+
<locations>
5+
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
6+
<repository location="http://download.eclipse.org/releases/2020-06"/>
7+
<unit id="org.eclipse.sdk.feature.group" version="4.16.0.v20200604-0951"/>
8+
</location>
9+
<location includeSource="true" missingManifest="generate" type="Maven">
10+
<dependencies>
11+
<dependency>
12+
<groupId>com.sun.xml.ws</groupId>
13+
<artifactId>jaxws-ri</artifactId>
14+
<version>3.0.2</version>
15+
<type>pom</type>
16+
</dependency>
17+
</dependencies>
18+
</location>
19+
</locations>
20+
</target>

0 commit comments

Comments
 (0)