You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2017/02/14 14:57:21 UTC
lucene-solr:master: LUCENE-7693: Replace "org.apache." logic in
GetMavenDependenciesTask. (Daniel Collins, Christine Poerschke)
Repository: lucene-solr
Updated Branches:
refs/heads/master ec5ebb688 -> 738da0998
LUCENE-7693: Replace "org.apache." logic in GetMavenDependenciesTask. (Daniel Collins, Christine Poerschke)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/738da099
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/738da099
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/738da099
Branch: refs/heads/master
Commit: 738da0998a7fc02fd9eadfbe21108cf5087b4f17
Parents: ec5ebb6
Author: Christine Poerschke <cp...@apache.org>
Authored: Tue Feb 14 14:27:44 2017 +0000
Committer: Christine Poerschke <cp...@apache.org>
Committed: Tue Feb 14 14:27:44 2017 +0000
----------------------------------------------------------------------
lucene/CHANGES.txt | 3 +
lucene/demo/ivy.xml | 2 +-
lucene/test-framework/ivy.xml | 2 +-
lucene/tools/ivy.xml | 2 +-
.../dependencies/GetMavenDependenciesTask.java | 58 ++++++++++++++++++--
solr/contrib/extraction/ivy.xml | 2 +-
solr/test-framework/ivy.xml | 2 +-
7 files changed, 61 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/738da099/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 60a3e16..e4042da 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -178,6 +178,9 @@ Build
* LUCENE-7694: Update forbiddenapis to version 2.3. (Uwe Schindler)
+* LUCENE-7693: Replace "org.apache." logic in GetMavenDependenciesTask.
+ (Daniel Collins, Christine Poerschke)
+
Other
* LUCENE-7666: Fix typos in lucene-join package info javadoc.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/738da099/lucene/demo/ivy.xml
----------------------------------------------------------------------
diff --git a/lucene/demo/ivy.xml b/lucene/demo/ivy.xml
index 050f0a5..5dd7e74 100644
--- a/lucene/demo/ivy.xml
+++ b/lucene/demo/ivy.xml
@@ -17,7 +17,7 @@
under the License.
-->
<ivy-module version="2.0">
- <info organisation="org.apache.lucene" module="core-demo"/>
+ <info organisation="org.apache.lucene" module="demo"/>
<configurations defaultconfmapping="compile->master">
<conf name="compile" transitive="false"/>
</configurations>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/738da099/lucene/test-framework/ivy.xml
----------------------------------------------------------------------
diff --git a/lucene/test-framework/ivy.xml b/lucene/test-framework/ivy.xml
index a71c25a..a51716c 100644
--- a/lucene/test-framework/ivy.xml
+++ b/lucene/test-framework/ivy.xml
@@ -17,7 +17,7 @@
under the License.
-->
<ivy-module version="2.0">
- <info organisation="org.apache.lucene" module="core-test-framework"/>
+ <info organisation="org.apache.lucene" module="test-framework"/>
<configurations defaultconfmapping="compile->master">
<conf name="compile" transitive="false"/>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/738da099/lucene/tools/ivy.xml
----------------------------------------------------------------------
diff --git a/lucene/tools/ivy.xml b/lucene/tools/ivy.xml
index 614aa8e..1fa2974 100644
--- a/lucene/tools/ivy.xml
+++ b/lucene/tools/ivy.xml
@@ -17,7 +17,7 @@
under the License.
-->
<ivy-module version="2.0">
- <info organisation="org.apache.lucene" module="core-tools"/>
+ <info organisation="org.apache.lucene" module="tools"/>
<configurations defaultconfmapping="compile->master">
<conf name="compile" transitive="false"/>
</configurations>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/738da099/lucene/tools/src/java/org/apache/lucene/dependencies/GetMavenDependenciesTask.java
----------------------------------------------------------------------
diff --git a/lucene/tools/src/java/org/apache/lucene/dependencies/GetMavenDependenciesTask.java b/lucene/tools/src/java/org/apache/lucene/dependencies/GetMavenDependenciesTask.java
index 45a9d11..5b2f0b8 100644
--- a/lucene/tools/src/java/org/apache/lucene/dependencies/GetMavenDependenciesTask.java
+++ b/lucene/tools/src/java/org/apache/lucene/dependencies/GetMavenDependenciesTask.java
@@ -54,6 +54,7 @@ import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
+import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -118,6 +119,7 @@ public class GetMavenDependenciesTask extends Task {
private final DocumentBuilder documentBuilder;
private File ivyCacheDir;
private Pattern internalJarPattern;
+ private Map<String,String> ivyModuleInfo;
/**
@@ -189,6 +191,8 @@ public class GetMavenDependenciesTask extends Task {
internalJarPattern = Pattern.compile(".*(lucene|solr)([^/]*?)-"
+ Pattern.quote(getProject().getProperty("version")) + "\\.jar");
+ ivyModuleInfo = getIvyModuleInfo(ivyXmlResources, documentBuilder, xpath);
+
setInternalDependencyProperties(); // side-effect: all modules' internal deps are recorded
setExternalDependencyProperties(); // side-effect: all modules' external deps are recorded
setGrandparentDependencyManagementProperty(); // uses deps recorded in above two methods
@@ -220,10 +224,56 @@ public class GetMavenDependenciesTask extends Task {
}
/**
+ * Visits all ivy.xml files and collects module and organisation attributes into a map.
+ */
+ private static Map<String,String> getIvyModuleInfo(Resources ivyXmlResources,
+ DocumentBuilder documentBuilder, XPath xpath) {
+ Map<String,String> ivyInfoModuleToOrganisation = new HashMap<String,String>();
+ traverseIvyXmlResources(ivyXmlResources, new Consumer<File>() {
+ @Override
+ public void accept(File f) {
+ try {
+ Document document = documentBuilder.parse(f);
+ {
+ String infoPath = "/ivy-module/info";
+ NodeList infos = (NodeList)xpath.evaluate(infoPath, document, XPathConstants.NODESET);
+ for (int infoNum = 0 ; infoNum < infos.getLength() ; ++infoNum) {
+ Element infoElement = (Element)infos.item(infoNum);
+ String infoOrg = infoElement.getAttribute("organisation");
+ String infoOrgSuffix = infoOrg.substring(infoOrg.lastIndexOf('.')+1);
+ String infoModule = infoElement.getAttribute("module");
+ String module = infoOrgSuffix+"-"+infoModule;
+ ivyInfoModuleToOrganisation.put(module, infoOrg);
+ }
+ }
+ } catch (XPathExpressionException | IOException | SAXException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ return ivyInfoModuleToOrganisation;
+ }
+
+ /**
* Collects external dependencies from each ivy.xml file and sets
* external dependency properties to be inserted into modules' POMs.
*/
private void setExternalDependencyProperties() {
+ traverseIvyXmlResources(ivyXmlResources, new Consumer<File>() {
+ @Override
+ public void accept(File f) {
+ try {
+ collectExternalDependenciesFromIvyXmlFile(f);
+ } catch (XPathExpressionException | IOException | SAXException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ addSharedExternalDependencies();
+ setExternalDependencyXmlProperties();
+ }
+
+ private static void traverseIvyXmlResources(Resources ivyXmlResources, Consumer<File> ivyXmlFileConsumer) {
@SuppressWarnings("unchecked")
Iterator<Resource> iter = (Iterator<Resource>)ivyXmlResources.iterator();
while (iter.hasNext()) {
@@ -238,15 +288,13 @@ public class GetMavenDependenciesTask extends Task {
File ivyXmlFile = ((FileResource)resource).getFile();
try {
- collectExternalDependenciesFromIvyXmlFile(ivyXmlFile);
+ ivyXmlFileConsumer.accept(ivyXmlFile);
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException("Exception reading file " + ivyXmlFile.getPath() + ": " + e, e);
}
}
- addSharedExternalDependencies();
- setExternalDependencyXmlProperties();
}
/**
@@ -396,7 +444,7 @@ public class GetMavenDependenciesTask extends Task {
}
}
}
- String groupId = "org.apache." + artifactId.substring(0, artifactId.indexOf('-'));
+ String groupId = ivyModuleInfo.get(artifactId);
appendDependencyXml(builder, groupId, artifactId, " ", "${project.version}", false, false, null, exclusions);
}
}
@@ -581,7 +629,7 @@ public class GetMavenDependenciesTask extends Task {
continue; // skip external (/(test-)lib/), and non-jar and unwanted (self) internal deps
}
String artifactId = dependencyToArtifactId(newPropertyKey, dependency);
- String groupId = "org.apache." + artifactId.substring(0, artifactId.indexOf('-'));
+ String groupId = ivyModuleInfo.get(artifactId);
String coordinate = groupId + ':' + artifactId;
sortedDeps.add(coordinate);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/738da099/solr/contrib/extraction/ivy.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/extraction/ivy.xml b/solr/contrib/extraction/ivy.xml
index 5cf19a1..42cee8a 100644
--- a/solr/contrib/extraction/ivy.xml
+++ b/solr/contrib/extraction/ivy.xml
@@ -17,7 +17,7 @@
under the License.
-->
<ivy-module version="2.0">
- <info organisation="org.apache.solr" module="extraction"/>
+ <info organisation="org.apache.solr" module="cell"/>
<configurations defaultconfmapping="compile->master;test->master">
<conf name="compile" transitive="false"/>
<conf name="test" transitive="false"/>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/738da099/solr/test-framework/ivy.xml
----------------------------------------------------------------------
diff --git a/solr/test-framework/ivy.xml b/solr/test-framework/ivy.xml
index 7ba1b2d..e203b46 100644
--- a/solr/test-framework/ivy.xml
+++ b/solr/test-framework/ivy.xml
@@ -17,7 +17,7 @@
under the License.
-->
<ivy-module version="2.0">
- <info organisation="org.apache.solr" module="solr-test-framework"/>
+ <info organisation="org.apache.solr" module="test-framework"/>
<configurations defaultconfmapping="compile->master;junit4-stdalone->master">
<conf name="compile" transitive="false" />