mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-15 14:04: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"]
|
||||
----
|
||||
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
|
||||
@ -785,8 +785,8 @@ Or if you are using Gradle:
|
||||
|
||||
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
compile("javax.cache:cache-api")
|
||||
compile("org.ehcache:ehcache")
|
||||
implementation("javax.cache:cache-api")
|
||||
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
|
||||
|
@ -448,7 +448,8 @@ public class ProjectGenerator {
|
||||
// Gradle plugin has changed as from 1.3.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
|
||||
model.put("springBootPluginName", (VERSION_1_4_2_M1.compareTo(bootVersion) <= 0)
|
||||
@ -482,6 +483,17 @@ public class ProjectGenerator {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -89,17 +89,17 @@ ext {
|
||||
{{/buildPropertiesVersions.empty}}
|
||||
dependencies {
|
||||
{{#compileDependencies}}
|
||||
compile('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||
{{gradleCompileConfig}}('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||
{{/compileDependencies}}
|
||||
{{#groovy}}
|
||||
compile('org.codehaus.groovy:groovy')
|
||||
{{gradleCompileConfig}}('org.codehaus.groovy:groovy')
|
||||
{{/groovy}}
|
||||
{{#kotlin}}
|
||||
compile("org.jetbrains.kotlin:{{kotlinStdlibArtifactId}}{{^kotlinSupport}}:${kotlinVersion}{{/kotlinSupport}}")
|
||||
compile("org.jetbrains.kotlin:kotlin-reflect{{^kotlinSupport}}:${kotlinVersion}{{/kotlinSupport}}")
|
||||
{{gradleCompileConfig}}("org.jetbrains.kotlin:{{kotlinStdlibArtifactId}}{{^kotlinSupport}}:${kotlinVersion}{{/kotlinSupport}}")
|
||||
{{gradleCompileConfig}}("org.jetbrains.kotlin:kotlin-reflect{{^kotlinSupport}}:${kotlinVersion}{{/kotlinSupport}}")
|
||||
{{/kotlin}}
|
||||
{{#runtimeDependencies}}
|
||||
runtime('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||
{{gradleRuntimeConfig}}('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||
{{/runtimeDependencies}}
|
||||
{{#compileOnlyDependencies}}
|
||||
compileOnly('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||
@ -110,9 +110,9 @@ dependencies {
|
||||
{{#providedDependencies}}
|
||||
providedRuntime('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||
{{/providedDependencies}}
|
||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
{{gradleTestCompileConfig}}('org.springframework.boot:spring-boot-starter-test')
|
||||
{{#testDependencies}}
|
||||
testCompile('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||
{{gradleTestCompileConfig}}('{{groupId}}:{{artifactId}}{{#version}}:{{version}}{{/version}}{{#type}}@{{type}}{{/type}}')
|
||||
{{/testDependencies}}
|
||||
}
|
||||
{{#hasBoms}}
|
||||
|
@ -598,7 +598,10 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
||||
.contains(
|
||||
"classpath('io.spring.gradle:dependency-management-plugin:0.5.9.RELEASE')")
|
||||
.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
|
||||
@ -612,6 +615,9 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
||||
generateGradleBuild(request)
|
||||
.contains("springBootVersion = '1.3.0.BUILD-SNAPSHOT'")
|
||||
.contains("apply plugin: 'spring-boot'")
|
||||
.contains("compile('org.springframework.boot:spring-boot-starter-web')")
|
||||
.contains(
|
||||
"testCompile('org.springframework.boot:spring-boot-starter-test')")
|
||||
.doesNotContain(
|
||||
"classpath('io.spring.gradle:dependency-management-plugin:0.5.9.RELEASE')")
|
||||
.doesNotContain("apply plugin: 'io.spring.dependency-management'");
|
||||
@ -624,6 +630,9 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
||||
generateGradleBuild(request)
|
||||
.contains("springBootVersion = '1.4.2.BUILD-SNAPSHOT'")
|
||||
.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'");
|
||||
}
|
||||
|
||||
@ -635,7 +644,11 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
||||
.contains("springBootVersion = '2.0.0.BUILD-SNAPSHOT'")
|
||||
.contains("apply plugin: 'org.springframework.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
|
||||
|
@ -45,8 +45,8 @@ repositories {
|
||||
|
||||
|
||||
dependencies {
|
||||
compile('org.springframework.boot:spring-boot-starter')
|
||||
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
compile("org.jetbrains.kotlin:kotlin-reflect")
|
||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
implementation('org.springframework.boot:spring-boot-starter')
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
testImplementation('org.springframework.boot:spring-boot-starter-test')
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ repositories {
|
||||
|
||||
|
||||
dependencies {
|
||||
compile('org.springframework.boot:spring-boot-starter')
|
||||
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
compile("org.jetbrains.kotlin:kotlin-reflect")
|
||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
implementation('org.springframework.boot:spring-boot-starter')
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
testImplementation('org.springframework.boot:spring-boot-starter-test')
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ repositories {
|
||||
|
||||
|
||||
dependencies {
|
||||
compile('org.springframework.boot:spring-boot-starter')
|
||||
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
|
||||
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
|
||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
implementation('org.springframework.boot:spring-boot-starter')
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
|
||||
testImplementation('org.springframework.boot:spring-boot-starter-test')
|
||||
}
|
||||
|
@ -95,9 +95,10 @@ public class ProjectGenerationSmokeTests
|
||||
page.type("gradle-project");
|
||||
page.submit();
|
||||
assertSimpleProject().isGradleProject().gradleBuildAssert()
|
||||
.contains("compile('org.springframework.boot:spring-boot-starter')")
|
||||
.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
|
||||
|
Loading…
Reference in New Issue
Block a user