SOLR-5950: Maven config: make the org.slf4j:slf4j-api dependency transitive (i.e., not optional) in all modules in which it's a dependency, including solrj, except for the WAR, where it will remain optional.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1584473 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Steven Rowe 2014-04-03 23:49:08 +00:00
parent 02804f67aa
commit 3df0ae45f6
2 changed files with 36 additions and 19 deletions

View File

@ -92,17 +92,19 @@ public class GetMavenDependenciesTask extends Task {
private static final Properties allProperties = new Properties();
private static final Set<String> modulesWithSeparateCompileAndTestPOMs = new HashSet<>();
private static final Set<String> optionalExternalDependencies = new HashSet<>();
private static final Set<String> globalOptionalExternalDependencies = new HashSet<>();
private static final Map<String,Set<String>> perModuleOptionalExternalDependencies = new HashMap<>();
static {
// Add modules here that have split compile and test POMs
// - they need compile-scope deps to also be test-scope deps.
modulesWithSeparateCompileAndTestPOMs.addAll
(Arrays.asList("lucene-core", "lucene-codecs", "solr-core", "solr-solrj"));
// Add external dependencies here that should be optional (i.e., not invoke Maven's transitive dep mechanism).
// Add external dependencies here that should be optional for all modules
// (i.e., not invoke Maven's transitive dependency mechanism).
// Format is "groupId:artifactId"
optionalExternalDependencies.addAll(Arrays.asList
("org.slf4j:jcl-over-slf4j", "org.slf4j:jul-to-slf4j", "org.slf4j:slf4j-api", "org.slf4j:slf4j-log4j12"));
globalOptionalExternalDependencies.addAll(Arrays.asList
("org.slf4j:jcl-over-slf4j", "org.slf4j:jul-to-slf4j", "org.slf4j:slf4j-log4j12"));
}
private final XPath xpath = XPathFactory.newInstance().newXPath();
@ -241,7 +243,7 @@ public class GetMavenDependenciesTask extends Task {
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException("Exception reading file " + ivyXmlFile.getPath(), e);
throw new BuildException("Exception reading file " + ivyXmlFile.getPath() + ": " + e, e);
}
}
addSharedExternalDependencies();
@ -257,10 +259,10 @@ public class GetMavenDependenciesTask extends Task {
// Delay adding shared compile-scope dependencies until after all have been processed,
// so dependency sharing is limited to a depth of one.
Map<String,SortedSet<ExternalDependency>> sharedDependencies = new HashMap<>();
for (String artifactId : interModuleExternalCompileScopeDependencies.keySet()) {
for (String module : interModuleExternalCompileScopeDependencies.keySet()) {
TreeSet<ExternalDependency> deps = new TreeSet<>();
sharedDependencies.put(artifactId, deps);
Set<String> moduleDependencies = interModuleExternalCompileScopeDependencies.get(artifactId);
sharedDependencies.put(module, deps);
Set<String> moduleDependencies = interModuleExternalCompileScopeDependencies.get(module);
if (null != moduleDependencies) {
for (String otherArtifactId : moduleDependencies) {
SortedSet<ExternalDependency> otherExtDeps = allExternalDependencies.get(otherArtifactId);
@ -274,13 +276,13 @@ public class GetMavenDependenciesTask extends Task {
}
}
}
for (String artifactId : interModuleExternalTestScopeDependencies.keySet()) {
SortedSet<ExternalDependency> deps = sharedDependencies.get(artifactId);
for (String module : interModuleExternalTestScopeDependencies.keySet()) {
SortedSet<ExternalDependency> deps = sharedDependencies.get(module);
if (null == deps) {
deps = new TreeSet<>();
sharedDependencies.put(artifactId, deps);
sharedDependencies.put(module, deps);
}
Set<String> moduleDependencies = interModuleExternalTestScopeDependencies.get(artifactId);
Set<String> moduleDependencies = interModuleExternalTestScopeDependencies.get(module);
if (null != moduleDependencies) {
for (String otherArtifactId : moduleDependencies) {
int testScopePos = otherArtifactId.indexOf(":test");
@ -294,8 +296,8 @@ public class GetMavenDependenciesTask extends Task {
for (ExternalDependency otherDep : otherExtDeps) {
if (otherDep.isTestDependency == isTestScope) {
if ( ! deps.contains(otherDep)
&& ( null == allExternalDependencies.get(artifactId)
|| ! allExternalDependencies.get(artifactId).contains(otherDep))) {
&& ( null == allExternalDependencies.get(module)
|| ! allExternalDependencies.get(module).contains(otherDep))) {
// Add test-scope clone only if it's not already a compile-scope dependency.
ExternalDependency otherDepTestScope = new ExternalDependency
(otherDep.groupId, otherDep.artifactId, otherDep.classifier, true, otherDep.isOptional);
@ -307,13 +309,21 @@ public class GetMavenDependenciesTask extends Task {
}
}
}
for (String artifactId : sharedDependencies.keySet()) {
SortedSet<ExternalDependency> deps = allExternalDependencies.get(artifactId);
for (String module : sharedDependencies.keySet()) {
SortedSet<ExternalDependency> deps = allExternalDependencies.get(module);
if (null == deps) {
deps = new TreeSet<>();
allExternalDependencies.put(artifactId, deps);
allExternalDependencies.put(module, deps);
}
for (ExternalDependency dep : sharedDependencies.get(module)) {
String dependencyCoordinate = dep.groupId + ":" + dep.artifactId;
if (globalOptionalExternalDependencies.contains(dependencyCoordinate)
|| (perModuleOptionalExternalDependencies.containsKey(module)
&& perModuleOptionalExternalDependencies.get(module).contains(dependencyCoordinate))) {
dep = new ExternalDependency(dep.groupId, dep.artifactId, dep.classifier, dep.isTestDependency, true);
}
deps.add(dep);
}
deps.addAll(sharedDependencies.get(artifactId));
}
}
@ -671,7 +681,9 @@ public class GetMavenDependenciesTask extends Task {
}
String conf = dependency.getAttribute("conf");
boolean confContainsTest = conf.contains("test");
boolean isOptional = optionalExternalDependencies.contains(dependencyCoordinate);
boolean isOptional = globalOptionalExternalDependencies.contains(dependencyCoordinate)
|| ( perModuleOptionalExternalDependencies.containsKey(module)
&& perModuleOptionalExternalDependencies.get(module).contains(dependencyCoordinate));
SortedSet<ExternalDependency> deps = allExternalDependencies.get(module);
if (null == deps) {
deps = new TreeSet<>();

View File

@ -188,6 +188,11 @@ Bug Fixes
* SOLR-5951: Fixed SolrDispatchFilter to throw useful exception on startup if
SLF4j logging jars are missing. (Uwe Schindler, Hossman, Shawn Heisey)
* SOLR-5950: Maven config: make the org.slf4j:slf4j-api dependency transitive
(i.e., not optional) in all modules in which it's a dependency, including
solrj, except for the WAR, where it will remain optional.
(Uwe Schindler, Steve Rowe)
Optimizations
----------------------
* SOLR-1880: Distributed Search skips GET_FIELDS stage if EXECUTE_QUERY