-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pass quarkus args to dev mode gradle task
- Loading branch information
1 parent
d6ceae4
commit 1d0cee3
Showing
6 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
integration-tests/gradle/src/main/resources/basic-java-main-application-project/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
plugins { | ||
id 'java' | ||
id 'io.quarkus' | ||
id 'application' | ||
} | ||
|
||
repositories { | ||
mavenLocal { | ||
content { | ||
includeGroupByRegex 'io.quarkus.*' | ||
} | ||
} | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") | ||
implementation 'io.quarkus:quarkus-arc' | ||
} | ||
|
||
compileJava { | ||
options.compilerArgs << '-parameters' | ||
} | ||
|
||
application { | ||
mainClass = 'org.acme.EntryPoint' | ||
} | ||
|
||
run { | ||
// propagate the custom local maven repo, in case it's configured | ||
if (System.properties.containsKey('maven.repo.local')) { | ||
systemProperty 'maven.repo.local', System.properties.get('maven.repo.local') | ||
} | ||
} | ||
|
||
test { | ||
systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager" | ||
} |
2 changes: 2 additions & 0 deletions
2
...ion-tests/gradle/src/main/resources/basic-java-main-application-project/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
quarkusPlatformArtifactId=quarkus-bom | ||
quarkusPlatformGroupId=io.quarkus |
15 changes: 15 additions & 0 deletions
15
...ation-tests/gradle/src/main/resources/basic-java-main-application-project/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenLocal { | ||
content { | ||
includeGroupByRegex 'io.quarkus.*' | ||
} | ||
} | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
plugins { | ||
id 'io.quarkus' version "${quarkusPluginVersion}" | ||
} | ||
} | ||
rootProject.name='code-with-quarkus' |
15 changes: 15 additions & 0 deletions
15
...main/resources/basic-java-main-application-project/src/main/java/org/acme/EntryPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.acme; | ||
|
||
import java.util.Arrays; | ||
|
||
import io.quarkus.runtime.Quarkus; | ||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
|
||
@QuarkusMain | ||
public class EntryPoint { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("basic-java-main-application-project: args.length: " + args.length); | ||
System.out.println("basic-java-main-application-project: args: " + Arrays.toString(args)); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...le/src/test/java/io/quarkus/gradle/devmode/BasicJavaMainApplicationModuleDevModeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package io.quarkus.gradle.devmode; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.awaitility.Awaitility.await; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.RandomAccessFile; | ||
import java.nio.file.Files; | ||
import java.util.Arrays; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.jboss.logging.Logger; | ||
import org.junit.jupiter.api.condition.DisabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
|
||
@DisabledOnOs(OS.WINDOWS) | ||
public class BasicJavaMainApplicationModuleDevModeTest extends QuarkusDevGradleTestBase { | ||
private static final Logger LOG = Logger.getLogger(BasicJavaMainApplicationModuleDevModeTest.class); | ||
|
||
private static final String ARGS_LOG_LINE_PREFIX = "basic-java-main-application-project: args"; | ||
|
||
@Override | ||
protected String projectDirectoryName() { | ||
return "basic-java-main-application-project"; | ||
} | ||
|
||
@Override | ||
protected String[] buildArguments() { | ||
return new String[] { "clean", "quarkusDev", "-s", "-Dquarkus.args=param1=1 param2=2 param3=3" }; | ||
} | ||
|
||
protected void testDevMode() throws Exception { | ||
System.out.println("testDevMode()..."); | ||
File logOutput = new File(projectDir, "command-output.log"); | ||
await().atMost(30, TimeUnit.SECONDS).until(() -> { | ||
try { | ||
String logLine; | ||
RandomAccessFile commandOutputLogFile = new RandomAccessFile(logOutput, "r"); | ||
while ((logLine = commandOutputLogFile.readLine()) != null) { | ||
if (logLine.startsWith(ARGS_LOG_LINE_PREFIX)) { | ||
commandOutputLogFile.close(); | ||
return true; | ||
} | ||
} | ||
commandOutputLogFile.close(); | ||
return false; | ||
} catch (Exception e) { | ||
LOG.error(String.format("e: <message, %s>, <cause, %s>", e.getMessage(), e.getCause())); | ||
LOG.info("e: " + Arrays.toString(e.getStackTrace())); | ||
return false; | ||
} | ||
}); | ||
String argsLengthLogLine = null; | ||
String argsLogLine = null; | ||
if (logOutput.exists()) { | ||
try (BufferedReader reader = Files.newBufferedReader(logOutput.toPath())) { | ||
String line = reader.readLine(); | ||
while (line != null) { | ||
if (line.contains(ARGS_LOG_LINE_PREFIX)) { | ||
if (line.contains("length")) { | ||
argsLengthLogLine = line; | ||
} else { | ||
argsLogLine = line; | ||
} | ||
} | ||
line = reader.readLine(); | ||
} | ||
} | ||
} | ||
assertThat(argsLengthLogLine).isNotNull(); | ||
assertThat(argsLengthLogLine).isNotEmpty(); | ||
assertThat(argsLogLine).isNotNull(); | ||
assertThat(argsLogLine).isNotEmpty(); | ||
assertThat(argsLengthLogLine).contains("basic-java-main-application-project: args.length: 3"); | ||
assertThat(argsLogLine).contains("basic-java-main-application-project: args: [param1=1, param2=2, param3=3]"); | ||
} | ||
} |