Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass quarkus args to dev mode gradle task #31318

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ private QuarkusDevModeLauncher newLauncher(final AnalyticsService analyticsServi
.debug(System.getProperty("debug"))
.debugHost(System.getProperty("debugHost"))
.debugPort(System.getProperty("debugPort"))
.applicationArgs(System.getProperty("quarkus.args"))
.suspend(System.getProperty("suspend"));
if (System.getProperty(IO_QUARKUS_DEVMODE_ARGS) == null) {
builder.jvmArgs("-Dquarkus.console.basic=true")
Expand Down
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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus
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'
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));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package io.quarkus.gradle.devmode;

Check failure on line 1 in integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/BasicJavaMainApplicationModuleDevModeTest.java

View check run for this annotation

quarkus-bot / Build summary for e4fc7cdebc3b8bf5fac6ea524e97ffd2a048810e

Gradle Tests - JDK 17

org.awaitility.core.ConditionTimeoutException: Condition with Lambda expression in io.quarkus.gradle.devmode.BasicJavaMainApplicationModuleDevModeTest was not fulfilled within 30 seconds. at app//org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167) at app//org.awaitility.core.CallableCondition.await(CallableCondition.java:78)
Raw output
org.awaitility.core.ConditionTimeoutException: Condition with Lambda expression in io.quarkus.gradle.devmode.BasicJavaMainApplicationModuleDevModeTest was not fulfilled within 30 seconds.
	at app//org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at app//org.awaitility.core.CallableCondition.await(CallableCondition.java:78)
	at app//org.awaitility.core.CallableCondition.await(CallableCondition.java:26)
	at app//org.awaitility.core.ConditionFactory.until(ConditionFactory.java:1006)
	at app//org.awaitility.core.ConditionFactory.until(ConditionFactory.java:975)
	at app//io.quarkus.gradle.devmode.BasicJavaMainApplicationModuleDevModeTest.testDevMode(BasicJavaMainApplicationModuleDevModeTest.java:36)
	at app//io.quarkus.gradle.devmode.QuarkusDevGradleTestBase.main(QuarkusDevGradleTestBase.java:60)
	at java.base@17.0.11/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base@17.0.11/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base@17.0.11/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.util.concurrent.TimeoutException
	at java.base@17.0.11/java.util.concurrent.FutureTask.get(FutureTask.java:204)
	at app//org.awaitility.core.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:101)
	at app//org.awaitility.core.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:81)
	at app//org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:103)
	... 9 more

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]");
}
}
Loading