Remove start-class property from Maven build

If one rename the main application class everything works fine in the IDE
but fails on the command-line as the previous class name is hard-coded
in the POM. This is only strictly necessary when more than one main class
is present in the project.

Closes gh-120
This commit is contained in:
Stephane Nicoll
2015-06-09 11:42:26 +02:00
parent 1e85f535f2
commit 1a4c668ba5
5 changed files with 10 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ order.
=== Release 1.0.0 (In progress)
* https://github.com/spring-io/initializr/issues/120[#120]: remove start-class property from Maven build
* https://github.com/spring-io/initializr/issues/96[#96]: export service metrics to redis
* https://github.com/spring-io/initializr/issues/115[#115]: rename /metadata/service to /metadata/config
* https://github.com/spring-io/initializr/issues/89[#89]: better describe service capability

View File

@@ -20,7 +20,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>${packageName}.${applicationName}</start-class>
<java.version>${javaVersion}</java.version>
</properties>

View File

@@ -59,8 +59,8 @@ class ProjectGeneratorTests {
projectGenerator.listeners << listener
def request = createProjectRequest('web')
generateMavenPom(request).hasStartClass('demo.DemoApplication')
.hasNoRepository().hasSpringBootStarterDependency('web')
generateMavenPom(request).hasNoRepository()
.hasSpringBootStarterDependency('web')
verify(listener, times(1)).onGeneratedProject(request)
}
@@ -81,7 +81,7 @@ class ProjectGeneratorTests {
def request = createProjectRequest('web')
generateProject(request).isJavaProject().isMavenProject().pomAssert()
.hasStartClass('demo.DemoApplication').hasNoRepository().hasSpringBootStarterDependency('web')
.hasNoRepository().hasSpringBootStarterDependency('web')
verify(listener, times(1)).onGeneratedProject(request)
}
@@ -96,8 +96,8 @@ class ProjectGeneratorTests {
void mavenPomWithBootSnapshot() {
def request = createProjectRequest('web')
request.bootVersion = '1.0.1.BUILD-SNAPSHOT'
generateMavenPom(request).hasStartClass('demo.DemoApplication')
.hasSnapshotRepository().hasSpringBootStarterDependency('web')
generateMavenPom(request).hasSnapshotRepository()
.hasSpringBootStarterDependency('web')
}
@Test
@@ -110,7 +110,7 @@ class ProjectGeneratorTests {
projectGenerator.metadata = metadata
def request = createProjectRequest('thymeleaf')
generateMavenPom(request).hasStartClass('demo.DemoApplication')
generateMavenPom(request)
.hasDependency('org.foo', 'thymeleaf')
.hasDependenciesCount(2)
}
@@ -127,7 +127,7 @@ class ProjectGeneratorTests {
def request = createProjectRequest('thymeleaf')
request.packaging = 'war'
generateProject(request).isJavaWarProject().isMavenProject().
pomAssert().hasStartClass('demo.DemoApplication')
pomAssert()
.hasSpringBootStarterTomcat()
.hasDependency('org.foo', 'thymeleaf') // This is tagged as web facet so it brings the web one
.hasSpringBootStarterTest()
@@ -138,7 +138,7 @@ class ProjectGeneratorTests {
void mavenWarPomWithoutWebFacet() {
def request = createProjectRequest('data-jpa')
request.packaging = 'war'
generateMavenPom(request).hasStartClass('demo.DemoApplication')
generateMavenPom(request)
.hasSpringBootStarterTomcat()
.hasSpringBootStarterDependency('data-jpa')
.hasSpringBootStarterDependency('web') // Added by war packaging

View File

@@ -102,11 +102,6 @@ class PomAssert {
this
}
PomAssert hasStartClass(String fqn) {
assertEquals fqn, eng.evaluate(createPropertyNodeXpath('start-class'), doc)
this
}
PomAssert hasDependenciesCount(int count) {
assertEquals "Wrong number of declared dependencies -->'${dependencies.keySet()}",
count, dependencies.size()

View File

@@ -36,7 +36,7 @@ class MainControllerDefaultsIntegrationTests extends AbstractInitializrControlle
def content = restTemplate.getForObject(createUrl('/pom.xml?style=web'), String)
def pomAssert = new PomAssert(content)
pomAssert.hasGroupId('org.foo').hasArtifactId('foo-bar').hasVersion('1.2.4-SNAPSHOT').hasPackaging('jar')
.hasName('FooBar').hasDescription('FooBar Project').hasStartClass('org.foo.demo.FooBarApplication')
.hasName('FooBar').hasDescription('FooBar Project')
}
@Test