Skip to content

Commit

Permalink
Keep template files compatible with Maven plugin < 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Mar 26, 2020
1 parent 36ca017 commit a2a8a84
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ compileTestJava {
}

java {
sourceCompatibility = JavaVersion.VERSION_${java_target}
targetCompatibility = JavaVersion.VERSION_${java_target}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>${java_target}</maven.compiler.source>
<maven.compiler.target>${java_target}</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.parameters>true</maven.compiler.parameters>

<quarkus.platform.artifact-id>${bom_artifactId}</quarkus.platform.artifact-id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ allOpen {
}

java {
sourceCompatibility = JavaVersion.VERSION_${java_target}
targetCompatibility = JavaVersion.VERSION_${java_target}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_${java_target}
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
kotlinOptions.javaParameters = true
}

compileTestKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_${java_target}
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>${java_target}</maven.compiler.source>
<maven.compiler.target>${java_target}</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.parameters>true</maven.compiler.parameters>

<quarkus.platform.artifact-id>${bom_artifactId}</quarkus.platform.artifact-id>
Expand Down Expand Up @@ -107,7 +107,7 @@
</executions>
<configuration>
<javaParameters>true</javaParameters>
<jvmTarget>${java_target}</jvmTarget>
<jvmTarget>1.8</jvmTarget>
<!-- Soon to be replaced by plugin that will pre-configure all necessary annotations -->
<compilerPlugins>
<plugin>all-open</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ version '${project_version}'

compileScala {
scalaCompileOptions.encoding = 'UTF-8'
sourceCompatibility = JavaVersion.VERSION_${java_target}
targetCompatibility = JavaVersion.VERSION_${java_target}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

java {
sourceCompatibility = JavaVersion.VERSION_${java_target}
targetCompatibility = JavaVersion.VERSION_${java_target}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>${java_target}</maven.compiler.source>
<maven.compiler.target>${java_target}</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.parameters>true</maven.compiler.parameters>

<quarkus.platform.artifact-id>${bom_artifactId}</quarkus.platform.artifact-id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public QuarkusCommandOutcome execute() throws QuarkusCommandException {
Matcher matcher = JAVA_VERSION_PATTERN
.matcher(this.javaTarget != null ? this.javaTarget : System.getProperty("java.version", ""));
if (matcher.matches() && Integer.parseInt(matcher.group(1)) < 11) {
invocation.setProperty(JAVA_TARGET, invocation.getBuildTool() == BuildTool.MAVEN ? "1.8" : "1_8");
invocation.setProperty(JAVA_TARGET, "8");
} else {
invocation.setProperty(JAVA_TARGET, "11");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.generators.rest;

import static io.quarkus.generators.ProjectGenerator.JAVA_TARGET;
import static java.lang.String.format;

import io.quarkus.cli.commands.QuarkusCommandInvocation;
Expand Down Expand Up @@ -144,6 +145,24 @@ private void generate(final String templateName, QuarkusCommandInvocation invoca
template = template.replace(format("${%s}", e.getKey().toString()), e.getValue().toString());
}
}

// do some nasty replacements for Java target if we want to generate Java 11 projects
if ("11".equals(invocation.getProperty(JAVA_TARGET))) {
if (BuildTool.GRADLE.equals(invocation.getBuildTool())) {
template = template.replace("JavaVersion.VERSION_1_8", "JavaVersion.VERSION_11");
} else {
template = template.replace("<maven.compiler.source>1.8</maven.compiler.source>",
"<maven.compiler.source>11</maven.compiler.source>");
template = template.replace("<maven.compiler.target>1.8</maven.compiler.target>",
"<maven.compiler.target>11</maven.compiler.target>");
// Kotlin
template = template.replace("<jvmTarget>1.8</jvmTarget>", "<jvmTarget>11</jvmTarget>");
// Scala
// For now, we keep Java 8 as a target for Scala as we don't want to upgrade to 2.13
// template = template.replace("<arg>-target:jvm-1.8</arg>", "<arg>-target:jvm-11</arg>");
}
}

writer.write(outputFilePath, template);
}
}
Expand Down

0 comments on commit a2a8a84

Please sign in to comment.