mirror of
https://gitee.com/dcren/initializr.git
synced 2026-02-25 21:22:58 +08:00
Add support for Groovy 4
Closes gh-1312
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -28,9 +28,16 @@ import io.spring.initializr.generator.spring.build.BuildCustomizer;
|
|||||||
*/
|
*/
|
||||||
class GroovyDependenciesConfigurer implements BuildCustomizer<Build> {
|
class GroovyDependenciesConfigurer implements BuildCustomizer<Build> {
|
||||||
|
|
||||||
|
private final boolean isUsingGroovy4;
|
||||||
|
|
||||||
|
GroovyDependenciesConfigurer(boolean isUsingGroovy4) {
|
||||||
|
this.isUsingGroovy4 = isUsingGroovy4;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(Build build) {
|
public void customize(Build build) {
|
||||||
build.dependencies().add("groovy", "org.codehaus.groovy", "groovy", DependencyScope.COMPILE);
|
String groupId = this.isUsingGroovy4 ? "org.apache.groovy" : "org.codehaus.groovy";
|
||||||
|
build.dependencies().add("groovy", groupId, "groovy", DependencyScope.COMPILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -36,6 +36,8 @@ import io.spring.initializr.generator.spring.build.BuildCustomizer;
|
|||||||
import io.spring.initializr.generator.spring.code.MainApplicationTypeCustomizer;
|
import io.spring.initializr.generator.spring.code.MainApplicationTypeCustomizer;
|
||||||
import io.spring.initializr.generator.spring.code.ServletInitializerCustomizer;
|
import io.spring.initializr.generator.spring.code.ServletInitializerCustomizer;
|
||||||
import io.spring.initializr.generator.spring.code.TestApplicationTypeCustomizer;
|
import io.spring.initializr.generator.spring.code.TestApplicationTypeCustomizer;
|
||||||
|
import io.spring.initializr.generator.version.VersionParser;
|
||||||
|
import io.spring.initializr.generator.version.VersionRange;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -49,6 +51,8 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@Configuration
|
@Configuration
|
||||||
class GroovyProjectGenerationDefaultContributorsConfiguration {
|
class GroovyProjectGenerationDefaultContributorsConfiguration {
|
||||||
|
|
||||||
|
private static final VersionRange GROOVY4 = VersionParser.DEFAULT.parseRange("3.0.0-M2");
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
MainApplicationTypeCustomizer<GroovyTypeDeclaration> mainMethodContributor() {
|
MainApplicationTypeCustomizer<GroovyTypeDeclaration> mainMethodContributor() {
|
||||||
return (typeDeclaration) -> typeDeclaration.addMethodDeclaration(
|
return (typeDeclaration) -> typeDeclaration.addMethodDeclaration(
|
||||||
@@ -69,8 +73,8 @@ class GroovyProjectGenerationDefaultContributorsConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
BuildCustomizer<Build> groovyDependenciesConfigurer() {
|
BuildCustomizer<Build> groovyDependenciesConfigurer(ProjectDescription description) {
|
||||||
return new GroovyDependenciesConfigurer();
|
return new GroovyDependenciesConfigurer(GROOVY4.match(description.getPlatformVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -87,6 +87,17 @@ class BuildComplianceTests extends AbstractComplianceTests {
|
|||||||
new ClassPathResource("project/" + language + "/standard/" + getAssertFileName(fileName)));
|
new ClassPathResource("project/" + language + "/standard/" + getAssertFileName(fileName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("parameters")
|
||||||
|
void nextGenerationJarGroovy(BuildSystem build, String fileName) {
|
||||||
|
testNextGenerationJar(new GroovyLanguage("17"), build, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testNextGenerationJar(Language language, BuildSystem build, String fileName) {
|
||||||
|
assertThat(generateProject(language, build, "3.0.0")).textFile(fileName).hasSameContentAs(
|
||||||
|
new ClassPathResource("project/" + language + "/next/" + getAssertFileName(fileName)));
|
||||||
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("parameters")
|
@MethodSource("parameters")
|
||||||
void currentGenerationWarJava(BuildSystem build, String fileName) {
|
void currentGenerationWarJava(BuildSystem build, String fileName) {
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
id 'org.springframework.boot' version '3.0.0'
|
||||||
|
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
|
||||||
|
id 'groovy'
|
||||||
|
}
|
||||||
|
|
||||||
|
group = 'com.example'
|
||||||
|
version = '0.0.1-SNAPSHOT'
|
||||||
|
sourceCompatibility = '17'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter'
|
||||||
|
implementation 'org.apache.groovy:groovy'
|
||||||
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named('test') {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
id("org.springframework.boot") version "3.0.0"
|
||||||
|
id("io.spring.dependency-management") version "1.0.6.RELEASE"
|
||||||
|
groovy
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "com.example"
|
||||||
|
version = "0.0.1-SNAPSHOT"
|
||||||
|
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter")
|
||||||
|
implementation("org.apache.groovy:groovy")
|
||||||
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test> {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.example</groupId>
|
||||||
|
<artifactId>demo</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>demo</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.groovy</groupId>
|
||||||
|
<artifactId>groovy</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.gmavenplus</groupId>
|
||||||
|
<artifactId>gmavenplus-plugin</artifactId>
|
||||||
|
<version>1.13.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>addSources</goal>
|
||||||
|
<goal>addTestSources</goal>
|
||||||
|
<goal>generateStubs</goal>
|
||||||
|
<goal>compile</goal>
|
||||||
|
<goal>generateTestStubs</goal>
|
||||||
|
<goal>compileTests</goal>
|
||||||
|
<goal>removeStubs</goal>
|
||||||
|
<goal>removeTestStubs</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
Reference in New Issue
Block a user