mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-20 02:29:44 +08:00
Allow to define "non starter" dependency
Previously, all dependencies were considered equal and enough to compile and start the simple auto-generated boot application. There are some corner cases such as the JDBC drivers and the new Ratpack integration. This commit adds an extra flag on a dependency that determines if it is a starter or not (the default is true). When no starter dependency has been selected for the project, the root starter (`spring-boot-starter`) is automatically added. Closes gh-159
This commit is contained in:
@@ -88,10 +88,11 @@ initializr:
|
|||||||
- name: Ratpack
|
- name: Ratpack
|
||||||
id: ratpack
|
id: ratpack
|
||||||
description: Spring Boot integration for the Ratpack framework
|
description: Spring Boot integration for the Ratpack framework
|
||||||
versionRange: 1.2.0.RELEASE
|
|
||||||
version: 1.1.1
|
|
||||||
groupId: io.ratpack
|
groupId: io.ratpack
|
||||||
artifactId: ratpack-spring-boot
|
artifactId: ratpack-spring-boot
|
||||||
|
version: 1.1.1
|
||||||
|
versionRange: 1.2.0.RELEASE
|
||||||
|
starter: false
|
||||||
- name: Vaadin
|
- name: Vaadin
|
||||||
id: vaadin
|
id: vaadin
|
||||||
facets:
|
facets:
|
||||||
@@ -449,12 +450,14 @@ initializr:
|
|||||||
groupId: com.h2database
|
groupId: com.h2database
|
||||||
artifactId: h2
|
artifactId: h2
|
||||||
scope: runtime
|
scope: runtime
|
||||||
|
starter: false
|
||||||
- name: HSQLDB
|
- name: HSQLDB
|
||||||
id: hsql
|
id: hsql
|
||||||
description: HSQLDB database (with embedded support)
|
description: HSQLDB database (with embedded support)
|
||||||
groupId: org.hsqldb
|
groupId: org.hsqldb
|
||||||
artifactId: hsqldb
|
artifactId: hsqldb
|
||||||
scope: runtime
|
scope: runtime
|
||||||
|
starter: false
|
||||||
- name: Apache Derby
|
- name: Apache Derby
|
||||||
id: derby
|
id: derby
|
||||||
description: Apache Derby database (with embedded support)
|
description: Apache Derby database (with embedded support)
|
||||||
@@ -462,12 +465,14 @@ initializr:
|
|||||||
artifactId: derby
|
artifactId: derby
|
||||||
scope: runtime
|
scope: runtime
|
||||||
versionRange: 1.2.2.RELEASE
|
versionRange: 1.2.2.RELEASE
|
||||||
|
starter: false
|
||||||
- name: MySQL
|
- name: MySQL
|
||||||
id: mysql
|
id: mysql
|
||||||
description: MySQL jdbc driver
|
description: MySQL jdbc driver
|
||||||
groupId: mysql
|
groupId: mysql
|
||||||
artifactId: mysql-connector-java
|
artifactId: mysql-connector-java
|
||||||
scope: runtime
|
scope: runtime
|
||||||
|
starter: false
|
||||||
- name: PostgreSQL
|
- name: PostgreSQL
|
||||||
id: postgresql
|
id: postgresql
|
||||||
description: PostgreSQL jdbc driver
|
description: PostgreSQL jdbc driver
|
||||||
@@ -475,6 +480,7 @@ initializr:
|
|||||||
artifactId: postgresql
|
artifactId: postgresql
|
||||||
version: 9.4-1201-jdbc41
|
version: 9.4-1201-jdbc41
|
||||||
scope: runtime
|
scope: runtime
|
||||||
|
starter: false
|
||||||
- name: Social
|
- name: Social
|
||||||
content:
|
content:
|
||||||
- name: Facebook
|
- name: Facebook
|
||||||
|
@@ -174,7 +174,8 @@ class ProjectRequest {
|
|||||||
resolvedDependencies << metadata.dependencies.get('web')
|
resolvedDependencies << metadata.dependencies.get('web')
|
||||||
facets << 'web'
|
facets << 'web'
|
||||||
}
|
}
|
||||||
if (resolvedDependencies.isEmpty()) {
|
if (!resolvedDependencies.find { it.starter }) {
|
||||||
|
// There's no starter so we add the default one
|
||||||
addDefaultDependency()
|
addDefaultDependency()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,6 +65,12 @@ class Dependency extends MetadataElement {
|
|||||||
|
|
||||||
int weight
|
int weight
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify if the dependency represents a "starter", i.e. the sole presence of
|
||||||
|
* that dependency is enough to bootstrap the context.
|
||||||
|
*/
|
||||||
|
boolean starter = true
|
||||||
|
|
||||||
List<String> keywords = []
|
List<String> keywords = []
|
||||||
|
|
||||||
void setScope(String scope) {
|
void setScope(String scope) {
|
||||||
|
@@ -457,6 +457,37 @@ class ProjectGeneratorTests {
|
|||||||
.hasRepository('http://example.com/repo')
|
.hasRepository('http://example.com/repo')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void projectWithOnlyStarterDependency() {
|
||||||
|
def foo = new Dependency(id: 'foo', groupId: 'org.foo', artifactId: 'custom-my-starter')
|
||||||
|
def metadata = InitializrMetadataTestBuilder.withDefaults()
|
||||||
|
.addDependencyGroup('foo', foo).build()
|
||||||
|
projectGenerator.metadata = metadata
|
||||||
|
|
||||||
|
def request = createProjectRequest('foo')
|
||||||
|
generateMavenPom(request)
|
||||||
|
.hasDependency('org.foo', 'custom-my-starter')
|
||||||
|
.hasSpringBootStarterTest()
|
||||||
|
.hasDependenciesCount(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void projectWithOnlyNonStarterDependency() {
|
||||||
|
def foo = new Dependency(id: 'foo', groupId: 'org.foo', artifactId: 'foo')
|
||||||
|
foo.starter = false
|
||||||
|
def metadata = InitializrMetadataTestBuilder.withDefaults()
|
||||||
|
.addDependencyGroup('foo', foo).build()
|
||||||
|
projectGenerator.metadata = metadata
|
||||||
|
|
||||||
|
def request = createProjectRequest('foo')
|
||||||
|
generateMavenPom(request)
|
||||||
|
.hasDependency('org.foo', 'foo')
|
||||||
|
.hasSpringBootStarterRootDependency()
|
||||||
|
.hasSpringBootStarterTest()
|
||||||
|
.hasDependenciesCount(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PomAssert generateMavenPom(ProjectRequest request) {
|
PomAssert generateMavenPom(ProjectRequest request) {
|
||||||
def content = new String(projectGenerator.generateMavenPom(request))
|
def content = new String(projectGenerator.generateMavenPom(request))
|
||||||
new PomAssert(content).validateProjectRequest(request)
|
new PomAssert(content).validateProjectRequest(request)
|
||||||
|
@@ -60,6 +60,7 @@
|
|||||||
"aliases": [],
|
"aliases": [],
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"weight": 0,
|
"weight": 0,
|
||||||
|
"starter": true,
|
||||||
"artifactId": "spring-boot-starter-web",
|
"artifactId": "spring-boot-starter-web",
|
||||||
"description": "Web dependency description",
|
"description": "Web dependency description",
|
||||||
"facets": ["web"],
|
"facets": ["web"],
|
||||||
@@ -72,6 +73,7 @@
|
|||||||
"aliases": [],
|
"aliases": [],
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"weight": 0,
|
"weight": 0,
|
||||||
|
"starter": true,
|
||||||
"artifactId": "spring-boot-starter-security",
|
"artifactId": "spring-boot-starter-security",
|
||||||
"facets": [],
|
"facets": [],
|
||||||
"groupId": "org.springframework.boot",
|
"groupId": "org.springframework.boot",
|
||||||
@@ -83,6 +85,7 @@
|
|||||||
"aliases": ["jpa"],
|
"aliases": ["jpa"],
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"weight": 0,
|
"weight": 0,
|
||||||
|
"starter": true,
|
||||||
"artifactId": "spring-boot-starter-data-jpa",
|
"artifactId": "spring-boot-starter-data-jpa",
|
||||||
"facets": [],
|
"facets": [],
|
||||||
"groupId": "org.springframework.boot",
|
"groupId": "org.springframework.boot",
|
||||||
@@ -103,6 +106,7 @@
|
|||||||
"id": "org.acme:foo",
|
"id": "org.acme:foo",
|
||||||
"name": "Foo",
|
"name": "Foo",
|
||||||
"weight": 42,
|
"weight": 42,
|
||||||
|
"starter": true,
|
||||||
"keywords": ["thefoo", "dafoo"],
|
"keywords": ["thefoo", "dafoo"],
|
||||||
"scope": "compile",
|
"scope": "compile",
|
||||||
"version": "1.3.5"
|
"version": "1.3.5"
|
||||||
@@ -111,6 +115,7 @@
|
|||||||
"aliases": [],
|
"aliases": [],
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"weight": 0,
|
"weight": 0,
|
||||||
|
"starter": true,
|
||||||
"artifactId": "bar",
|
"artifactId": "bar",
|
||||||
"facets": [],
|
"facets": [],
|
||||||
"groupId": "org.acme",
|
"groupId": "org.acme",
|
||||||
@@ -123,6 +128,7 @@
|
|||||||
"aliases": [],
|
"aliases": [],
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"weight": 0,
|
"weight": 0,
|
||||||
|
"starter": true,
|
||||||
"artifactId": "biz",
|
"artifactId": "biz",
|
||||||
"facets": [],
|
"facets": [],
|
||||||
"groupId": "org.acme",
|
"groupId": "org.acme",
|
||||||
@@ -136,6 +142,7 @@
|
|||||||
"aliases": [],
|
"aliases": [],
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"weight": 0,
|
"weight": 0,
|
||||||
|
"starter": true,
|
||||||
"artifactId": "bur",
|
"artifactId": "bur",
|
||||||
"facets": [],
|
"facets": [],
|
||||||
"groupId": "org.acme",
|
"groupId": "org.acme",
|
||||||
@@ -149,6 +156,7 @@
|
|||||||
"aliases": [],
|
"aliases": [],
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"weight": 0,
|
"weight": 0,
|
||||||
|
"starter": true,
|
||||||
"artifactId": "my-api",
|
"artifactId": "my-api",
|
||||||
"facets": [],
|
"facets": [],
|
||||||
"groupId": "org.acme",
|
"groupId": "org.acme",
|
||||||
|
Reference in New Issue
Block a user