Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikolaj Izdebski2016-06-13 11:14:03 +0000
committerAlexander Kurtakov2019-05-17 10:29:34 +0000
commit83251cd5c5a523b0568a043ff7e050901d11cf90 (patch)
treef24915dc0d3bb1da90d477074360df4be4f48bc5
parent2af2e4068d5e3b41d539dd5bb1adb93b8625f0c3 (diff)
downloadorg.eclipse.tycho.extras-83251cd5c5a523b0568a043ff7e050901d11cf90.tar.gz
org.eclipse.tycho.extras-83251cd5c5a523b0568a043ff7e050901d11cf90.tar.xz
org.eclipse.tycho.extras-83251cd5c5a523b0568a043ff7e050901d11cf90.zip
Set location for pomless models
Core Maven model reader sets location and some tools depend on these values. These tools won't work with tycho-pomless unless it also sets the location. Signed-off-by: Mikolaj Izdebski <mizdebsk@redhat.com> Change-Id: I4da47c995c1333db0bb0ddb31f7309b08bf5ff39
-rw-r--r--tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java11
-rw-r--r--tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java18
2 files changed, 28 insertions, 1 deletions
diff --git a/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java b/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java
index 8035abf..e62cd57 100644
--- a/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java
+++ b/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java
@@ -26,6 +26,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.maven.model.Build;
+import org.apache.maven.model.InputLocation;
+import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin;
@@ -89,6 +91,7 @@ public class TychoModelReader extends ModelReaderSupport {
String bundleVersion = getRequiredHeaderValue("Bundle-Version", headers, manifestFile);
model.setVersion(getPomVersion(bundleVersion));
model.setPackaging(getPackagingType(bundleSymbolicName));
+ setLocation(model, manifestFile);
return model;
}
@@ -149,6 +152,7 @@ public class TychoModelReader extends ModelReaderSupport {
}
model.setVersion(getPomVersion(versionNode.getValue()));
// groupId is inherited from parent pom
+ setLocation(model, xmlFile);
return model;
}
@@ -237,4 +241,11 @@ public class TychoModelReader extends ModelReaderSupport {
parentReference.setVersion(version);
return parentReference;
}
+
+ private void setLocation(Model model, File modelSource) {
+ InputSource inputSource = new InputSource();
+ inputSource.setLocation(modelSource.toString());
+ inputSource.setModelId(model.getParent().getGroupId() + ":" + model.getArtifactId() + ":" + model.getVersion());
+ model.setLocation("", new InputLocation(0, 0, inputSource));
+ }
}
diff --git a/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java b/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java
index d9f2394..f7c2bd3 100644
--- a/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java
+++ b/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 SAP SE and others.
+ * Copyright (c) 2015, 2019 SAP SE and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,6 +19,8 @@ import java.io.Reader;
import java.util.HashMap;
import java.util.Map;
+import org.apache.maven.model.InputLocation;
+import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.building.ModelProcessor;
@@ -45,6 +47,7 @@ public class TychoModelReaderTest extends PlexusTestCase {
assertEquals("0.1.0-SNAPSHOT", model.getVersion());
assertEquals("eclipse-plugin", model.getPackaging());
assertParent(model.getParent());
+ assertLocation("bundle1/META-INF/MANIFEST.MF", model.getLocation(""));
}
@Test
@@ -55,6 +58,7 @@ public class TychoModelReaderTest extends PlexusTestCase {
assertEquals("1.0.1", model.getVersion());
assertEquals("eclipse-test-plugin", model.getPackaging());
assertParent(model.getParent());
+ assertLocation("bundle1.tests/META-INF/MANIFEST.MF", model.getLocation(""));
}
@Test
@@ -65,6 +69,7 @@ public class TychoModelReaderTest extends PlexusTestCase {
assertEquals("1.0.0-SNAPSHOT", model.getVersion());
assertEquals("eclipse-feature", model.getPackaging());
assertParent(model.getParent());
+ assertLocation("feature/feature.xml", model.getLocation(""));
}
@Test
@@ -204,6 +209,17 @@ public class TychoModelReaderTest extends PlexusTestCase {
assertEquals("0.0.1-SNAPSHOT", parent.getVersion());
}
+ private void assertLocation(String expectedLocation, InputLocation location) {
+ assertNotNull(location);
+ assertEquals(0, location.getLineNumber());
+ assertEquals(0, location.getColumnNumber());
+ InputSource source = location.getSource();
+ assertNotNull(source);
+ assertEquals(new File(getPolyglotTestDir(), expectedLocation).toString(), source.getLocation());
+ assertNotNull(source.getModelId());
+ assertTrue(source.getModelId().matches("^testParent.groupId:.*:.*"));
+ }
+
private Map<String, String> createReaderOptions(File buildProperties) {
Map<String, String> options = new HashMap<>();
options.put(ModelProcessor.SOURCE, buildProperties.getAbsolutePath());

Back to the top