Commit c6f930b4 authored by Phillip Webb's avatar Phillip Webb

Fix Gradle to use flattened POM file

Update the Gradle plugin to use version information from the
flattened POM.xml files.

See gh-9316
parent b87f9c11
...@@ -8,35 +8,13 @@ repositories { ...@@ -8,35 +8,13 @@ repositories {
mavenCentral() mavenCentral()
} }
def addDependency(configurationName, dependency) {
def coordinates = [
'group': dependency.groupId.text(),
'name': dependency.artifactId.text(),
'version': dependency.version.text()
]
dependencies {
add configurationName, coordinates
}
}
def effectivePomFile = file('target/effective-pom.xml')
if (effectivePomFile.file) {
def pom = new XmlSlurper().parseText(file('target/effective-pom.xml').text)
pom.dependencies.dependency.each { dependency ->
def scope = dependency.scope.text()
if (scope == 'compile') {
addDependency scope, dependency
}
else if (scope == 'test') {
addDependency 'testCompile', dependency
}
}
}
dependencies { dependencies {
compile localGroovy() compile localGroovy()
compile gradleApi() compile gradleApi()
compile fileTree(dir: 'target/dependencies/compile', include: '*.jar')
testCompile gradleTestKit() testCompile gradleTestKit()
testCompile 'org.apache.commons:commons-compress:1.13'
testCompile fileTree(dir: 'target/dependencies/test', include: '*.jar')
} }
jar { jar {
......
...@@ -196,7 +196,7 @@ public class GradleBuild implements TestRule { ...@@ -196,7 +196,7 @@ public class GradleBuild implements TestRule {
XPathFactory xPathFactory = XPathFactory.newInstance(); XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xpath = xPathFactory.newXPath(); XPath xpath = xPathFactory.newXPath();
XPathExpression expr = xpath.compile(expression); XPathExpression expr = xpath.compile(expression);
String version = expr.evaluate(new InputSource(new FileReader("pom.xml"))); String version = expr.evaluate(new InputSource(new FileReader(".flattened-pom.xml")));
return version; return version;
} }
catch (Exception ex) { catch (Exception ex) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment