mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-15 23:13:30 +08:00
Fix deprecated Gradle dependency configuration
See gh-730
This commit is contained in:
parent
495ac3213c
commit
2d2ffe4013
@ -39,7 +39,7 @@ Or if you are using Gradle:
|
|||||||
|
|
||||||
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
|
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
|
||||||
----
|
----
|
||||||
compile("io.spring.initializr:initializr-web:{spring-initializr-version}")
|
implementation("io.spring.initializr:initializr-web:{spring-initializr-version}")
|
||||||
----
|
----
|
||||||
|
|
||||||
NOTE: Spring Initializr releases are not available on Maven Central so you will need to
|
NOTE: Spring Initializr releases are not available on Maven Central so you will need to
|
||||||
@ -785,8 +785,8 @@ Or if you are using Gradle:
|
|||||||
|
|
||||||
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
|
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
|
||||||
----
|
----
|
||||||
compile("javax.cache:cache-api")
|
implementation("javax.cache:cache-api")
|
||||||
compile("org.ehcache:ehcache")
|
implementation("org.ehcache:ehcache")
|
||||||
----
|
----
|
||||||
|
|
||||||
You'll notice that the log entry is much more rare. If you do not want to use JSR-107, you
|
You'll notice that the log entry is much more rare. If you do not want to use JSR-107, you
|
||||||
|
@ -448,7 +448,8 @@ public class ProjectGenerator {
|
|||||||
// Gradle plugin has changed as from 1.3.0
|
// Gradle plugin has changed as from 1.3.0
|
||||||
model.put("bootOneThreeAvailable", VERSION_1_3_0_M1.compareTo(bootVersion) <= 0);
|
model.put("bootOneThreeAvailable", VERSION_1_3_0_M1.compareTo(bootVersion) <= 0);
|
||||||
|
|
||||||
model.put("bootTwoZeroAvailable", VERSION_2_0_0_M1.compareTo(bootVersion) <= 0);
|
final boolean bootTwoZeroAvailable = VERSION_2_0_0_M1.compareTo(bootVersion) <= 0;
|
||||||
|
model.put("bootTwoZeroAvailable", bootTwoZeroAvailable);
|
||||||
|
|
||||||
// Gradle plugin has changed again as from 1.4.2
|
// Gradle plugin has changed again as from 1.4.2
|
||||||
model.put("springBootPluginName", (VERSION_1_4_2_M1.compareTo(bootVersion) <= 0)
|
model.put("springBootPluginName", (VERSION_1_4_2_M1.compareTo(bootVersion) <= 0)
|
||||||
@ -482,6 +483,17 @@ public class ProjectGenerator {
|
|||||||
model.put("hasBoms", true);
|
model.put("hasBoms", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isGradleBuild(request)) {
|
||||||
|
model.put("gradleCompileConfig",
|
||||||
|
bootTwoZeroAvailable ? "implementation" : "compile");
|
||||||
|
model.put("gradleRuntimeConfig",
|
||||||
|
bootTwoZeroAvailable ? "runtimeOnly" : "runtime");
|
||||||
|
model.put("gradleTestCompileConfig",
|
||||||
|
bootTwoZeroAvailable ? "testImplementation" : "testCompile");
|
||||||
|
model.put("gradleTestRuntimeConfig",
|
||||||
|
bootTwoZeroAvailable ? "testRuntimeOnly" : "testRuntime");
|
||||||
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,17 +89,17 @@ ext {
|
|||||||
{{/buildPropertiesVersions.empty}}
|
{{/buildPropertiesVersions.empty}}
|
||||||
dependencies {
|
dependencies {
|
||||||
{{#compileDependencies}}
|
{{#compileDependencies}}
|
||||||
compile('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
{{gradleCompileConfig}}('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||||
{{/compileDependencies}}
|
{{/compileDependencies}}
|
||||||
{{#groovy}}
|
{{#groovy}}
|
||||||
compile('org.codehaus.groovy:groovy')
|
{{gradleCompileConfig}}('org.codehaus.groovy:groovy')
|
||||||
{{/groovy}}
|
{{/groovy}}
|
||||||
{{#kotlin}}
|
{{#kotlin}}
|
||||||
compile("org.jetbrains.kotlin:{{kotlinStdlibArtifactId}}{{^kotlinSupport}}:${kotlinVersion}{{/kotlinSupport}}")
|
{{gradleCompileConfig}}("org.jetbrains.kotlin:{{kotlinStdlibArtifactId}}{{^kotlinSupport}}:${kotlinVersion}{{/kotlinSupport}}")
|
||||||
compile("org.jetbrains.kotlin:kotlin-reflect{{^kotlinSupport}}:${kotlinVersion}{{/kotlinSupport}}")
|
{{gradleCompileConfig}}("org.jetbrains.kotlin:kotlin-reflect{{^kotlinSupport}}:${kotlinVersion}{{/kotlinSupport}}")
|
||||||
{{/kotlin}}
|
{{/kotlin}}
|
||||||
{{#runtimeDependencies}}
|
{{#runtimeDependencies}}
|
||||||
runtime('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
{{gradleRuntimeConfig}}('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||||
{{/runtimeDependencies}}
|
{{/runtimeDependencies}}
|
||||||
{{#compileOnlyDependencies}}
|
{{#compileOnlyDependencies}}
|
||||||
compileOnly('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
compileOnly('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||||
@ -110,9 +110,9 @@ dependencies {
|
|||||||
{{#providedDependencies}}
|
{{#providedDependencies}}
|
||||||
providedRuntime('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
providedRuntime('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||||
{{/providedDependencies}}
|
{{/providedDependencies}}
|
||||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
{{gradleTestCompileConfig}}('org.springframework.boot:spring-boot-starter-test')
|
||||||
{{#testDependencies}}
|
{{#testDependencies}}
|
||||||
testCompile('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
{{gradleTestCompileConfig}}('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||||
{{/testDependencies}}
|
{{/testDependencies}}
|
||||||
}
|
}
|
||||||
{{#hasBoms}}
|
{{#hasBoms}}
|
||||||
|
@ -598,7 +598,10 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
.contains(
|
.contains(
|
||||||
"classpath('io.spring.gradle:dependency-management-plugin:0.5.9.RELEASE')")
|
"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'")
|
||||||
|
.contains("compile('org.springframework.boot:spring-boot-starter-web')")
|
||||||
|
.contains(
|
||||||
|
"testCompile('org.springframework.boot:spring-boot-starter-test')");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -612,6 +615,9 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
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'")
|
||||||
|
.contains("compile('org.springframework.boot:spring-boot-starter-web')")
|
||||||
|
.contains(
|
||||||
|
"testCompile('org.springframework.boot:spring-boot-starter-test')")
|
||||||
.doesNotContain(
|
.doesNotContain(
|
||||||
"classpath('io.spring.gradle:dependency-management-plugin:0.5.9.RELEASE')")
|
"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'");
|
||||||
@ -624,6 +630,9 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
generateGradleBuild(request)
|
generateGradleBuild(request)
|
||||||
.contains("springBootVersion = '1.4.2.BUILD-SNAPSHOT'")
|
.contains("springBootVersion = '1.4.2.BUILD-SNAPSHOT'")
|
||||||
.contains("apply plugin: 'org.springframework.boot'")
|
.contains("apply plugin: 'org.springframework.boot'")
|
||||||
|
.contains("compile('org.springframework.boot:spring-boot-starter-web')")
|
||||||
|
.contains(
|
||||||
|
"testCompile('org.springframework.boot:spring-boot-starter-test')")
|
||||||
.doesNotContain("apply plugin: 'spring-boot'");
|
.doesNotContain("apply plugin: 'spring-boot'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,7 +644,11 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
|||||||
.contains("springBootVersion = '2.0.0.BUILD-SNAPSHOT'")
|
.contains("springBootVersion = '2.0.0.BUILD-SNAPSHOT'")
|
||||||
.contains("apply plugin: 'org.springframework.boot'")
|
.contains("apply plugin: 'org.springframework.boot'")
|
||||||
.doesNotContain("apply plugin: 'spring-boot'")
|
.doesNotContain("apply plugin: 'spring-boot'")
|
||||||
.contains("apply plugin: 'io.spring.dependency-management'");
|
.contains("apply plugin: 'io.spring.dependency-management'")
|
||||||
|
.contains(
|
||||||
|
"implementation('org.springframework.boot:spring-boot-starter-web')")
|
||||||
|
.contains(
|
||||||
|
"testImplementation('org.springframework.boot:spring-boot-starter-test')");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -45,8 +45,8 @@ repositories {
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile('org.springframework.boot:spring-boot-starter')
|
implementation('org.springframework.boot:spring-boot-starter')
|
||||||
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
compile("org.jetbrains.kotlin:kotlin-reflect")
|
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
testImplementation('org.springframework.boot:spring-boot-starter-test')
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ repositories {
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile('org.springframework.boot:spring-boot-starter')
|
implementation('org.springframework.boot:spring-boot-starter')
|
||||||
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
compile("org.jetbrains.kotlin:kotlin-reflect")
|
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
testImplementation('org.springframework.boot:spring-boot-starter-test')
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ repositories {
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile('org.springframework.boot:spring-boot-starter')
|
implementation('org.springframework.boot:spring-boot-starter')
|
||||||
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
|
||||||
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
|
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
|
||||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
testImplementation('org.springframework.boot:spring-boot-starter-test')
|
||||||
}
|
}
|
||||||
|
@ -95,9 +95,10 @@ public class ProjectGenerationSmokeTests
|
|||||||
page.type("gradle-project");
|
page.type("gradle-project");
|
||||||
page.submit();
|
page.submit();
|
||||||
assertSimpleProject().isGradleProject().gradleBuildAssert()
|
assertSimpleProject().isGradleProject().gradleBuildAssert()
|
||||||
.contains("compile('org.springframework.boot:spring-boot-starter')")
|
|
||||||
.contains(
|
.contains(
|
||||||
"testCompile('org.springframework.boot:spring-boot-starter-test')");
|
"implementation('org.springframework.boot:spring-boot-starter')")
|
||||||
|
.contains(
|
||||||
|
"testImplementation('org.springframework.boot:spring-boot-starter-test')");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user