Fix Gradle to use flattened POM file
Update the Gradle plugin to use version information from the flattened POM.xml files. See gh-9316
This commit is contained in:
parent
b87f9c11f1
commit
c6f930b49e
|
|
@ -8,35 +8,13 @@ repositories {
|
|||
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 {
|
||||
compile localGroovy()
|
||||
compile gradleApi()
|
||||
compile fileTree(dir: 'target/dependencies/compile', include: '*.jar')
|
||||
testCompile gradleTestKit()
|
||||
testCompile 'org.apache.commons:commons-compress:1.13'
|
||||
testCompile fileTree(dir: 'target/dependencies/test', include: '*.jar')
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ public class GradleBuild implements TestRule {
|
|||
XPathFactory xPathFactory = XPathFactory.newInstance();
|
||||
XPath xpath = xPathFactory.newXPath();
|
||||
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;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue