Re-apply GMavenPlus support

Closes gh-90
This commit is contained in:
Stephane Nicoll
2016-01-14 13:47:43 +01:00
parent 9ea01d9424
commit 9139d10669
6 changed files with 43 additions and 50 deletions

View File

@@ -9,6 +9,7 @@ order.
* https://github.com/spring-io/initializr/issues/107[#107]: pre-fill form based on URL parameters
* https://github.com/spring-io/initializr/issues/114[#114]: clean package name if necessary
* https://github.com/spring-io/initializr/issues/90[#90]: migrate Groovy maven-based builds to GMavenPlus
* https://github.com/spring-io/initializr/issues/140[#140]: expose dependencies meta-data
* https://github.com/spring-io/initializr/issues/168[#168]: support for dependency versions mapping
* https://github.com/spring-io/initializr/issues/165[#165]: improve resources caching

View File

@@ -152,30 +152,15 @@
</dependencyManagement>
<build>
<sourceDirectory>src/main/groovy</sourceDirectory>
<testSourceDirectory>src/test/groovy</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.3.7-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -189,6 +174,20 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@@ -202,12 +201,6 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
<extensions>true</extensions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -216,6 +209,11 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
</plugin>
</plugins>
</pluginManagement>
</build>

View File

@@ -102,7 +102,7 @@ class ProjectGenerator {
def applicationName = request.applicationName
def language = request.language
String codeLocation = ((language.equals("groovy") && gradleBuild) ? 'groovy': 'java')
String codeLocation = language.equals("groovy") ? 'groovy': 'java'
def src = new File(new File(dir, "src/main/$codeLocation"), request.packageName.replace('.', '/'))
src.mkdirs()
write(new File(src, "${applicationName}.${language}"), "Application.$language", model)

View File

@@ -78,28 +78,23 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin><% if (language=='groovy') { %>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.3.7-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
<extensions>true</extensions>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>testGenerateStubs</goal>
<goal>testCompile</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
</plugin><% } %>
</plugins>
</build>

View File

@@ -217,7 +217,7 @@ class ProjectGeneratorTests {
request.bootVersion = '1.1.9.RELEASE'
request.name = 'MyDemo'
request.packageName = 'foo'
generateProject(request).sourceCodeAssert('src/main/java/foo/MyDemoApplication.groovy')
generateProject(request).sourceCodeAssert('src/main/groovy/foo/MyDemoApplication.groovy')
.hasImports(EnableAutoConfiguration.class.name, ComponentScan.class.name, Configuration.class.name)
.doesNotHaveImports(SpringBootApplication.class.name)
.contains('@EnableAutoConfiguration', '@Configuration', '@ComponentScan')
@@ -231,7 +231,7 @@ class ProjectGeneratorTests {
request.bootVersion = '1.2.0.RC1'
request.name = 'MyDemo'
request.packageName = 'foo'
generateProject(request).sourceCodeAssert('src/main/java/foo/MyDemoApplication.groovy')
generateProject(request).sourceCodeAssert('src/main/groovy/foo/MyDemoApplication.groovy')
.hasImports(SpringBootApplication.class.name)
.doesNotHaveImports(EnableAutoConfiguration.class.name, ComponentScan.class.name, Configuration.class.name)
.contains('@SpringBootApplication')
@@ -257,7 +257,7 @@ class ProjectGeneratorTests {
}
@Test
void groovyWithMavenUsesJavaDir() {
void groovyWithMavenUsesGroovyDir() {
def request = createProjectRequest('web')
request.type = 'maven-project'
request.language = 'groovy'

View File

@@ -109,10 +109,9 @@ class ProjectAssert {
}
ProjectAssert isGroovyProject(String expectedPackageName, String expectedApplicationName) {
String codeLocation = (mavenProject ? 'java' : 'groovy')
String packageName = expectedPackageName.replace('.', '/')
hasFile("src/main/$codeLocation/$packageName/${expectedApplicationName}.groovy",
"src/test/$codeLocation/$packageName/${expectedApplicationName}Tests.groovy",
hasFile("src/main/groovy/$packageName/${expectedApplicationName}.groovy",
"src/test/groovy/$packageName/${expectedApplicationName}Tests.groovy",
'src/main/resources/application.properties')
}