Skip to content

Commit c6f930b

Browse files
committed
Fix Gradle to use flattened POM file
Update the Gradle plugin to use version information from the flattened POM.xml files. See gh-9316
1 parent b87f9c1 commit c6f930b

File tree

2 files changed

+4
-26
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin

2 files changed

+4
-26
lines changed

Diff for: spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle

+3-25
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,13 @@ repositories {
88
mavenCentral()
99
}
1010

11-
def addDependency(configurationName, dependency) {
12-
def coordinates = [
13-
'group': dependency.groupId.text(),
14-
'name': dependency.artifactId.text(),
15-
'version': dependency.version.text()
16-
]
17-
dependencies {
18-
add configurationName, coordinates
19-
}
20-
}
21-
22-
def effectivePomFile = file('target/effective-pom.xml')
23-
if (effectivePomFile.file) {
24-
def pom = new XmlSlurper().parseText(file('target/effective-pom.xml').text)
25-
pom.dependencies.dependency.each { dependency ->
26-
def scope = dependency.scope.text()
27-
if (scope == 'compile') {
28-
addDependency scope, dependency
29-
}
30-
else if (scope == 'test') {
31-
addDependency 'testCompile', dependency
32-
}
33-
}
34-
}
35-
3611
dependencies {
3712
compile localGroovy()
3813
compile gradleApi()
14+
compile fileTree(dir: 'target/dependencies/compile', include: '*.jar')
3915
testCompile gradleTestKit()
16+
testCompile 'org.apache.commons:commons-compress:1.13'
17+
testCompile fileTree(dir: 'target/dependencies/test', include: '*.jar')
4018
}
4119

4220
jar {

Diff for: spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private static String evaluateExpression(String expression) {
196196
XPathFactory xPathFactory = XPathFactory.newInstance();
197197
XPath xpath = xPathFactory.newXPath();
198198
XPathExpression expr = xpath.compile(expression);
199-
String version = expr.evaluate(new InputSource(new FileReader("pom.xml")));
199+
String version = expr.evaluate(new InputSource(new FileReader(".flattened-pom.xml")));
200200
return version;
201201
}
202202
catch (Exception ex) {

0 commit comments

Comments
 (0)