mirror of
https://gitee.com/dcren/initializr.git
synced 2026-02-26 05:32:58 +08:00
Support dependency version in Gradle
Previously, if a dependency defines an explicit version in the meta-data it was not defined properly in the gradle build file. Fixes gh-82
This commit is contained in:
@@ -7,6 +7,7 @@ order.
|
||||
|
||||
=== Release 1.0.0 (In progress)
|
||||
|
||||
* https://github.com/spring-io/initializr/issues/82[#82]: fix version support for gradle build
|
||||
* https://github.com/spring-io/initializr/issues/88[#88]: expose service meta-data so that another
|
||||
service can use that as a base configuration.
|
||||
* https://github.com/spring-io/initializr/issues/87[#87]: more flexible meta-data.
|
||||
|
||||
@@ -40,13 +40,13 @@ repositories {
|
||||
}
|
||||
<% } %>
|
||||
dependencies {<% compileDependencies.each { %>
|
||||
compile("${it.groupId}:${it.artifactId}")<% } %><% if (language=='groovy') { %>
|
||||
compile("${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}")<% } %><% if (language=='groovy') { %>
|
||||
compile("org.codehaus.groovy:groovy")<% } %><% runtimeDependencies.each { %>
|
||||
runtime("${it.groupId}:${it.artifactId}")<% } %><% if (packaging=='war') { %>
|
||||
runtime("${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}")<% } %><% if (packaging=='war') { %>
|
||||
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")<% } %><% providedDependencies.each { %>
|
||||
providedRuntime("${it.groupId}:${it.artifactId}")<% } %>
|
||||
providedRuntime("${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}")<% } %>
|
||||
testCompile("org.springframework.boot:spring-boot-starter-test") <% testDependencies.each { %>
|
||||
testCompile("${it.groupId}:${it.artifactId}")<% } %>
|
||||
testCompile("${it.groupId}:${it.artifactId}${it.version ? ":$it.version" : ""}")<% } %>
|
||||
}
|
||||
|
||||
eclipse {
|
||||
|
||||
@@ -232,6 +232,33 @@ class ProjectGeneratorTests {
|
||||
generateProject(request).isGradleProject().isGroovyProject()
|
||||
}
|
||||
|
||||
@Test
|
||||
void mavenPomWithCustomVersion() {
|
||||
def whatever = new Dependency(id: 'whatever', groupId: 'org.acme', artifactId: 'whatever', version: '1.2.3')
|
||||
def metadata = InitializrMetadataTestBuilder.withDefaults()
|
||||
.addDependencyGroup('core', 'web', 'security', 'data-jpa')
|
||||
.addDependencyGroup('foo', whatever).build()
|
||||
projectGenerator.metadata = metadata
|
||||
def request = createProjectRequest('whatever', 'data-jpa', 'web')
|
||||
generateMavenPom(request).hasDependency(whatever)
|
||||
.hasSpringBootStarterDependency('data-jpa')
|
||||
.hasSpringBootStarterDependency('web')
|
||||
}
|
||||
|
||||
@Test
|
||||
void gradleBuildWithCustomVersion() {
|
||||
def whatever = new Dependency(id: 'whatever', groupId: 'org.acme', artifactId: 'whatever', version: '1.2.3')
|
||||
def metadata = InitializrMetadataTestBuilder.withDefaults()
|
||||
.addDependencyGroup('core', 'web', 'security', 'data-jpa')
|
||||
.addDependencyGroup('foo', whatever).build()
|
||||
projectGenerator.metadata = metadata
|
||||
def request = createProjectRequest('whatever', 'data-jpa', 'web')
|
||||
generateGradleBuild(request)
|
||||
.contains("compile(\"org.springframework.boot:spring-boot-starter-web\")")
|
||||
.contains("compile(\"org.springframework.boot:spring-boot-starter-data-jpa\")")
|
||||
.contains("compile(\"org.acme:whatever:1.2.3\")")
|
||||
}
|
||||
|
||||
@Test
|
||||
void mavenPomWithCustomScope() {
|
||||
def h2 = new Dependency(id: 'h2', groupId: 'org.h2', artifactId: 'h2', scope: 'runtime')
|
||||
|
||||
Reference in New Issue
Block a user