From 1a4c668ba5a40ee6bb43fb7c739d9d1622f17bbf Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 9 Jun 2015 11:42:26 +0200 Subject: [PATCH] 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 --- CHANGELOG.adoc | 1 + .../src/main/resources/templates/starter-pom.xml | 1 - .../generator/ProjectGeneratorTests.groovy | 16 ++++++++-------- .../io/spring/initializr/test/PomAssert.groovy | 5 ----- ...MainControllerDefaultsIntegrationTests.groovy | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a3912a56..50879792 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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 diff --git a/initializr/src/main/resources/templates/starter-pom.xml b/initializr/src/main/resources/templates/starter-pom.xml index 8e3db099..38cc6518 100644 --- a/initializr/src/main/resources/templates/starter-pom.xml +++ b/initializr/src/main/resources/templates/starter-pom.xml @@ -20,7 +20,6 @@ UTF-8 - ${packageName}.${applicationName} ${javaVersion} diff --git a/initializr/src/test/groovy/io/spring/initializr/generator/ProjectGeneratorTests.groovy b/initializr/src/test/groovy/io/spring/initializr/generator/ProjectGeneratorTests.groovy index b7e563db..1c34d65b 100644 --- a/initializr/src/test/groovy/io/spring/initializr/generator/ProjectGeneratorTests.groovy +++ b/initializr/src/test/groovy/io/spring/initializr/generator/ProjectGeneratorTests.groovy @@ -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 diff --git a/initializr/src/test/groovy/io/spring/initializr/test/PomAssert.groovy b/initializr/src/test/groovy/io/spring/initializr/test/PomAssert.groovy index 1ae7a739..8fb4485c 100644 --- a/initializr/src/test/groovy/io/spring/initializr/test/PomAssert.groovy +++ b/initializr/src/test/groovy/io/spring/initializr/test/PomAssert.groovy @@ -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() diff --git a/initializr/src/test/groovy/io/spring/initializr/web/MainControllerDefaultsIntegrationTests.groovy b/initializr/src/test/groovy/io/spring/initializr/web/MainControllerDefaultsIntegrationTests.groovy index 41eb28f0..83372972 100644 --- a/initializr/src/test/groovy/io/spring/initializr/web/MainControllerDefaultsIntegrationTests.groovy +++ b/initializr/src/test/groovy/io/spring/initializr/web/MainControllerDefaultsIntegrationTests.groovy @@ -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