mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-19 10:08:22 +08:00
Group build properties under ext
Closes gh-781
This commit is contained in:
@@ -420,6 +420,9 @@ public class ProjectGenerator {
|
||||
model.put("buildPropertiesVersions", versions.entrySet());
|
||||
request.getBuildProperties().getVersions().forEach(
|
||||
(k, v) -> versions.put(computeVersionProperty(request, k), v.get()));
|
||||
if (!versions.isEmpty()) {
|
||||
model.put("hasBuildPropertiesVersions", true);
|
||||
}
|
||||
Map<String, String> gradle = new LinkedHashMap<>();
|
||||
model.put("buildPropertiesGradle", gradle.entrySet());
|
||||
request.getBuildProperties().getGradle()
|
||||
|
@@ -72,9 +72,13 @@ configurations {
|
||||
providedRuntime
|
||||
}
|
||||
{{/providedDependencies}}
|
||||
{{#hasBuildPropertiesVersions}}
|
||||
ext {
|
||||
{{#buildPropertiesVersions}}
|
||||
ext['{{key}}'] = '{{value}}'
|
||||
set('{{key}}', '{{value}}')
|
||||
{{/buildPropertiesVersions}}
|
||||
}
|
||||
{{/hasBuildPropertiesVersions}}
|
||||
|
||||
dependencies {
|
||||
{{#compileDependencies}}
|
||||
|
@@ -718,8 +718,8 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
||||
request.getBuildProperties().getMaven().put("ignore.property", () -> "yes");
|
||||
|
||||
generateGradleBuild(request).contains("name = 'test'")
|
||||
.contains("ext['foo.version'] = '1.2.3'")
|
||||
.contains("ext['internalVersion'] = '4.5.6'")
|
||||
.contains("set('foo.version', '1.2.3')")
|
||||
.contains("set('internalVersion', '4.5.6')")
|
||||
.doesNotContain("ignore.property");
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,9 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
ext['fooVersion'] = '1.3.3'
|
||||
ext {
|
||||
set('fooVersion', '1.3.3')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation('org.acme:foo')
|
||||
|
@@ -23,8 +23,10 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
ext['springBarVersion'] = '0.2.0.RELEASE'
|
||||
ext['spring-foo.version'] = '0.1.0.RELEASE'
|
||||
ext {
|
||||
set('springBarVersion', '0.2.0.RELEASE')
|
||||
set('spring-foo.version', '0.1.0.RELEASE')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation('org.springframework.boot:spring-boot-starter-web')
|
||||
|
Reference in New Issue
Block a user