Blame SOURCES/fix-xmvn-pomless-builddep.patch

2a5430
From d33893c3e3ea8f4be7636439a8f9011bb179a8e9 Mon Sep 17 00:00:00 2001
2a5430
From: Mikolaj Izdebski <mizdebsk@redhat.com>
2a5430
Date: Mon, 13 Jun 2016 13:14:03 +0200
2a5430
Subject: [PATCH] Set location for pomless models
2a5430
2a5430
Core Maven model reader sets location and some tools depend on these
2a5430
values.  These tools won't work with tycho-pomless unless it also sets
2a5430
the location.
2a5430
2a5430
Signed-off-by: Mikolaj Izdebski <mizdebsk@redhat.com>
2a5430
Change-Id: I4da47c995c1333db0bb0ddb31f7309b08bf5ff39
2a5430
---
2a5430
2a5430
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
2a5430
index 349c776..e8a4f92 100644
2a5430
--- a/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java
2a5430
+++ b/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoModelReader.java
2a5430
@@ -26,6 +26,8 @@
2a5430
 import javax.xml.parsers.DocumentBuilderFactory;
2a5430
 import javax.xml.parsers.ParserConfigurationException;
2a5430
 
2a5430
+import org.apache.maven.model.InputLocation;
2a5430
+import org.apache.maven.model.InputSource;
2a5430
 import org.apache.maven.model.Build;
2a5430
 import org.apache.maven.model.Model;
2a5430
 import org.apache.maven.model.Parent;
2a5430
@@ -90,6 +92,7 @@
2a5430
         String bundleVersion = getRequiredHeaderValue("Bundle-Version", headers, manifestFile);
2a5430
         model.setVersion(getPomVersion(bundleVersion));
2a5430
         model.setPackaging(getPackagingType(bundleSymbolicName));
2a5430
+        setLocation(model, manifestFile);
2a5430
         return model;
2a5430
     }
2a5430
 
2a5430
@@ -150,6 +153,7 @@
2a5430
         }
2a5430
         model.setVersion(getPomVersion(versionNode.getValue()));
2a5430
         // groupId is inherited from parent pom
2a5430
+        setLocation(model, xmlFile);
2a5430
         return model;
2a5430
     }
2a5430
 
2a5430
@@ -247,4 +251,11 @@
2a5430
         parentReference.setVersion(version);
2a5430
         return parentReference;
2a5430
     }
2a5430
+
2a5430
+    private void setLocation(Model model, File modelSource) {
2a5430
+        InputSource inputSource = new InputSource();
2a5430
+        inputSource.setLocation(modelSource.toString());
2a5430
+        inputSource.setModelId(model.getParent().getGroupId() + ":" + model.getArtifactId() + ":" + model.getVersion());
2a5430
+        model.setLocation("", new InputLocation(0, 0, inputSource));
2a5430
+    }
2a5430
 }
2a5430
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
2a5430
index 05cf0c2..a40e738 100644
2a5430
--- a/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java
2a5430
+++ b/tycho-pomless/src/test/java/org/eclipse/tycho/pomless/TychoModelReaderTest.java
2a5430
@@ -19,6 +19,8 @@
2a5430
 import java.util.HashMap;
2a5430
 import java.util.Map;
2a5430
 
2a5430
+import org.apache.maven.model.InputLocation;
2a5430
+import org.apache.maven.model.InputSource;
2a5430
 import org.apache.maven.model.Model;
2a5430
 import org.apache.maven.model.Parent;
2a5430
 import org.apache.maven.model.building.ModelProcessor;
2a5430
@@ -45,6 +47,7 @@
2a5430
         assertEquals("0.1.0-SNAPSHOT", model.getVersion());
2a5430
         assertEquals("eclipse-plugin", model.getPackaging());
2a5430
         assertParent(model.getParent());
2a5430
+        assertLocation("bundle1/META-INF/MANIFEST.MF", model.getLocation(""));
2a5430
     }
2a5430
 
2a5430
     @Test
2a5430
@@ -55,6 +58,7 @@
2a5430
         assertEquals("1.0.1", model.getVersion());
2a5430
         assertEquals("eclipse-test-plugin", model.getPackaging());
2a5430
         assertParent(model.getParent());
2a5430
+        assertLocation("bundle1.tests/META-INF/MANIFEST.MF", model.getLocation(""));
2a5430
     }
2a5430
 
2a5430
     @Test
2a5430
@@ -65,6 +69,7 @@
2a5430
         assertEquals("1.0.0-SNAPSHOT", model.getVersion());
2a5430
         assertEquals("eclipse-feature", model.getPackaging());
2a5430
         assertParent(model.getParent());
2a5430
+        assertLocation("feature/feature.xml", model.getLocation(""));
2a5430
     }
2a5430
 
2a5430
     @Test
2a5430
@@ -204,6 +209,17 @@
2a5430
         assertEquals("0.0.1-SNAPSHOT", parent.getVersion());
2a5430
     }
2a5430
 
2a5430
+    private void assertLocation(String expectedLocation, InputLocation location) {
2a5430
+        assertNotNull(location);
2a5430
+        assertEquals(0, location.getLineNumber());
2a5430
+        assertEquals(0, location.getColumnNumber());
2a5430
+        InputSource source = location.getSource();
2a5430
+        assertNotNull(source);
2a5430
+        assertEquals(new File(getPolyglotTestDir(), expectedLocation).toString(), source.getLocation());
2a5430
+        assertNotNull(source.getModelId());
2a5430
+        assertTrue(source.getModelId().matches("^testParent.groupId:.*:.*"));
2a5430
+    }
2a5430
+
2a5430
     private Map<String, String> createReaderOptions(File buildProperties) {
2a5430
         Map<String, String> options = new HashMap<>();
2a5430
         options.put(ModelProcessor.SOURCE, buildProperties.getAbsolutePath());