mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-15 23:13:30 +08:00
Externalize dependency management plugin version
Closes gh-253
This commit is contained in:
parent
1fd8e2c047
commit
6099a1c6bc
@ -225,7 +225,8 @@ class ProjectGenerator {
|
|||||||
model['providedDependencies'] = filterDependencies(dependencies, Dependency.SCOPE_PROVIDED)
|
model['providedDependencies'] = filterDependencies(dependencies, Dependency.SCOPE_PROVIDED)
|
||||||
model['testDependencies'] = filterDependencies(dependencies, Dependency.SCOPE_TEST)
|
model['testDependencies'] = filterDependencies(dependencies, Dependency.SCOPE_TEST)
|
||||||
|
|
||||||
// Add kotlinVersion
|
// Add various versions
|
||||||
|
model['dependencyManagementPluginVersion'] = metadata.configuration.env.gradle.dependencyManagementPluginVersion
|
||||||
model['kotlinVersion'] = metadata.configuration.env.kotlin.version
|
model['kotlinVersion'] = metadata.configuration.env.kotlin.version
|
||||||
|
|
||||||
// @SpringBootApplication available as from 1.2.0.RC1
|
// @SpringBootApplication available as from 1.2.0.RC1
|
||||||
|
@ -165,6 +165,11 @@ class InitializrConfiguration {
|
|||||||
*/
|
*/
|
||||||
final Map<String, Repository> repositories = [:]
|
final Map<String, Repository> repositories = [:]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gradle-specific settings.
|
||||||
|
*/
|
||||||
|
final Gradle gradle = new Gradle()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kotlin-specific settings.
|
* Kotlin-specific settings.
|
||||||
*/
|
*/
|
||||||
@ -203,6 +208,7 @@ class InitializrConfiguration {
|
|||||||
fallbackApplicationName = other.fallbackApplicationName
|
fallbackApplicationName = other.fallbackApplicationName
|
||||||
invalidApplicationNames = other.invalidApplicationNames
|
invalidApplicationNames = other.invalidApplicationNames
|
||||||
forceSsl = other.forceSsl
|
forceSsl = other.forceSsl
|
||||||
|
gradle.merge(other.gradle)
|
||||||
kotlin.version = other.kotlin.version
|
kotlin.version = other.kotlin.version
|
||||||
maven.merge(other.maven)
|
maven.merge(other.maven)
|
||||||
other.boms.each { id, bom ->
|
other.boms.each { id, bom ->
|
||||||
@ -217,6 +223,19 @@ class InitializrConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class Gradle {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version of the "dependency-management-plugin" to use.
|
||||||
|
*/
|
||||||
|
String dependencyManagementPluginVersion
|
||||||
|
|
||||||
|
private void merge(Gradle other) {
|
||||||
|
dependencyManagementPluginVersion = other.dependencyManagementPluginVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static class Kotlin {
|
static class Kotlin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +23,12 @@
|
|||||||
"sourceType": "io.spring.initializr.metadata.InitializrProperties",
|
"sourceType": "io.spring.initializr.metadata.InitializrProperties",
|
||||||
"sourceMethod": "getEnv()"
|
"sourceMethod": "getEnv()"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "initializr.env.gradle",
|
||||||
|
"type": "io.spring.initializr.metadata.InitializrConfiguration$Env$Gradle",
|
||||||
|
"sourceType": "io.spring.initializr.metadata.InitializrConfiguration$Env",
|
||||||
|
"sourceMethod": "getGradle()"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "initializr.env.kotlin",
|
"name": "initializr.env.kotlin",
|
||||||
"type": "io.spring.initializr.metadata.InitializrConfiguration$Env$Kotlin",
|
"type": "io.spring.initializr.metadata.InitializrConfiguration$Env$Kotlin",
|
||||||
@ -175,6 +181,12 @@
|
|||||||
"org.springframework"
|
"org.springframework"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "initializr.env.gradle.dependency-management-plugin-version",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "Version of the \"dependency-management-plugin\" to use.",
|
||||||
|
"sourceType": "io.spring.initializr.metadata.InitializrConfiguration$Env$Gradle"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "initializr.env.kotlin.version",
|
"name": "initializr.env.kotlin.version",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
|
@ -9,8 +9,8 @@ buildscript {
|
|||||||
maven { url "https://repo.spring.io/milestone" }<% } %>
|
maven { url "https://repo.spring.io/milestone" }<% } %>
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:\${springBootVersion}") <% if (!bootOneThreeAvailable) { %>
|
classpath("org.springframework.boot:spring-boot-gradle-plugin:\${springBootVersion}")<% if (!bootOneThreeAvailable) { %>
|
||||||
classpath('io.spring.gradle:dependency-management-plugin:0.6.0.RELEASE')<% } %><% if (language=='kotlin') { %>
|
classpath('io.spring.gradle:dependency-management-plugin:${dependencyManagementPluginVersion}')<% } %><% if (language=='kotlin') { %>
|
||||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:\${kotlinVersion}")<% } %>
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:\${kotlinVersion}")<% } %>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,8 +18,8 @@ buildscript {
|
|||||||
apply plugin: '${language}'<% if (packaging=='war') { %>
|
apply plugin: '${language}'<% if (packaging=='war') { %>
|
||||||
apply plugin: 'eclipse-wtp'<% } else { %>
|
apply plugin: 'eclipse-wtp'<% } else { %>
|
||||||
apply plugin: 'eclipse'<% } %>
|
apply plugin: 'eclipse'<% } %>
|
||||||
apply plugin: 'spring-boot' <% if (!bootOneThreeAvailable) { %>
|
apply plugin: 'spring-boot'<% if (!bootOneThreeAvailable) { %>
|
||||||
apply plugin: 'io.spring.dependency-management' <% } %><% if (packaging=='war') { %>
|
apply plugin: 'io.spring.dependency-management'<% } %><% if (packaging=='war') { %>
|
||||||
apply plugin: 'war'
|
apply plugin: 'war'
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ dependencies {<% compileDependencies.each { %>
|
|||||||
compile("org.jetbrains.kotlin:kotlin-stdlib:\${kotlinVersion}")<% } %><% runtimeDependencies.each { %>
|
compile("org.jetbrains.kotlin:kotlin-stdlib:\${kotlinVersion}")<% } %><% runtimeDependencies.each { %>
|
||||||
runtime('${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}${it.type ? "@$it.type" : ""}')<% } %><% providedDependencies.each { %>
|
runtime('${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}${it.type ? "@$it.type" : ""}')<% } %><% providedDependencies.each { %>
|
||||||
providedRuntime('${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}${it.type ? "@$it.type" : ""}')<% } %>
|
providedRuntime('${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}${it.type ? "@$it.type" : ""}')<% } %>
|
||||||
testCompile('org.springframework.boot:spring-boot-starter-test') <% testDependencies.each { %>
|
testCompile('org.springframework.boot:spring-boot-starter-test')<% testDependencies.each { %>
|
||||||
testCompile('${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}${it.type ? "@$it.type" : ""}')<% } %>
|
testCompile('${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}${it.type ? "@$it.type" : ""}')<% } %>
|
||||||
}
|
}
|
||||||
<% if (boms) { %>
|
<% if (boms) { %>
|
||||||
|
@ -411,23 +411,31 @@ class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gradleBuildBeforeWithSpringBoot13() {
|
void gradleBuildBeforeWithSpringBoot13() {
|
||||||
|
def metadata = InitializrMetadataTestBuilder.withDefaults()
|
||||||
|
.addDependencyGroup('core', 'web', 'jpa')
|
||||||
|
.setGradleEnv('0.5.9.RELEASE').build()
|
||||||
|
applyMetadata(metadata)
|
||||||
def request = createProjectRequest('web')
|
def request = createProjectRequest('web')
|
||||||
request.bootVersion = '1.2.3.RELEASE'
|
request.bootVersion = '1.2.3.RELEASE'
|
||||||
generateGradleBuild(request)
|
generateGradleBuild(request)
|
||||||
.contains("springBootVersion = '1.2.3.RELEASE'")
|
.contains("springBootVersion = '1.2.3.RELEASE'")
|
||||||
.contains("classpath('io.spring.gradle:dependency-management-plugin:0.6.0.RELEASE')")
|
.contains("classpath('io.spring.gradle:dependency-management-plugin:0.5.9.RELEASE')")
|
||||||
.contains("apply plugin: 'spring-boot'")
|
.contains("apply plugin: 'spring-boot'")
|
||||||
.contains("apply plugin: 'io.spring.dependency-management'")
|
.contains("apply plugin: 'io.spring.dependency-management'")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gradleBuildAsFromSpringBoot13() {
|
void gradleBuildAsFromSpringBoot13() {
|
||||||
|
def metadata = InitializrMetadataTestBuilder.withDefaults()
|
||||||
|
.addDependencyGroup('core', 'web', 'jpa')
|
||||||
|
.setGradleEnv('0.5.9.RELEASE').build()
|
||||||
|
applyMetadata(metadata)
|
||||||
def request = createProjectRequest('web')
|
def request = createProjectRequest('web')
|
||||||
request.bootVersion = '1.3.0.BUILD-SNAPSHOT'
|
request.bootVersion = '1.3.0.BUILD-SNAPSHOT'
|
||||||
generateGradleBuild(request)
|
generateGradleBuild(request)
|
||||||
.contains("springBootVersion = '1.3.0.BUILD-SNAPSHOT'")
|
.contains("springBootVersion = '1.3.0.BUILD-SNAPSHOT'")
|
||||||
.contains("apply plugin: 'spring-boot'")
|
.contains("apply plugin: 'spring-boot'")
|
||||||
.doesNotContain("classpath('io.spring.gradle:dependency-management-plugin:0.6.0.RELEASE')")
|
.doesNotContain("classpath('io.spring.gradle:dependency-management-plugin:0.5.9.RELEASE')")
|
||||||
.doesNotContain("apply plugin: 'io.spring.dependency-management'")
|
.doesNotContain("apply plugin: 'io.spring.dependency-management'")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ class InitializrMetadataTestBuilder {
|
|||||||
InitializrMetadataTestBuilder addDefaults() {
|
InitializrMetadataTestBuilder addDefaults() {
|
||||||
addDefaultTypes().addDefaultPackagings().addDefaultJavaVersions()
|
addDefaultTypes().addDefaultPackagings().addDefaultJavaVersions()
|
||||||
.addDefaultLanguages().addDefaultBootVersions()
|
.addDefaultLanguages().addDefaultBootVersions()
|
||||||
|
.setGradleEnv('0.5.1.RELEASE').setKotlinEnv('1.0.1')
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializrMetadataTestBuilder addDefaultTypes() {
|
InitializrMetadataTestBuilder addDefaultTypes() {
|
||||||
@ -152,6 +153,20 @@ class InitializrMetadataTestBuilder {
|
|||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InitializrMetadataTestBuilder setGradleEnv(String dependencyManagementPluginVersion) {
|
||||||
|
builder.withCustomizer {
|
||||||
|
it.configuration.env.gradle.dependencyManagementPluginVersion = dependencyManagementPluginVersion
|
||||||
|
}
|
||||||
|
this
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializrMetadataTestBuilder setKotlinEnv(String kotlinVersion) {
|
||||||
|
builder.withCustomizer {
|
||||||
|
it.configuration.env.kotlin.version = kotlinVersion
|
||||||
|
}
|
||||||
|
this
|
||||||
|
}
|
||||||
|
|
||||||
InitializrMetadataTestBuilder setMavenParent(String groupId, String artifactId,
|
InitializrMetadataTestBuilder setMavenParent(String groupId, String artifactId,
|
||||||
String version, boolean includeSpringBootBom) {
|
String version, boolean includeSpringBootBom) {
|
||||||
builder.withCustomizer {
|
builder.withCustomizer {
|
||||||
|
@ -46,6 +46,8 @@ initializr:
|
|||||||
artifactId: spring-cloud-services-dependencies
|
artifactId: spring-cloud-services-dependencies
|
||||||
version: 1.1.0.RELEASE
|
version: 1.1.0.RELEASE
|
||||||
additionalBoms: [cloud-bom]
|
additionalBoms: [cloud-bom]
|
||||||
|
gradle:
|
||||||
|
dependency-management-plugin-version: 0.6.0.RELEASE
|
||||||
kotlin:
|
kotlin:
|
||||||
version: 1.0.2
|
version: 1.0.2
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Loading…
Reference in New Issue
Block a user