-
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.
Browse files
Browse the repository at this point in the history
Support Java 21 main launch protocol
- Loading branch information
Showing
12 changed files
with
636 additions
and
9 deletions.
There are no files selected for viewing
216 changes: 207 additions & 9 deletions
216
core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java
Large diffs are not rendered by default.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
...ent/src/test/java/io/quarkus/commandmode/launch/IgnorePrivateMainCommandModeTestCase.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,48 @@ | ||
package io.quarkus.commandmode.launch; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class IgnorePrivateMainCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldSuperSuper.class, HelloWorldSuper.class, HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain extends HelloWorldSuper { | ||
|
||
private static void main(String[] args) { | ||
System.out.println("Private Static World"); | ||
} | ||
} | ||
|
||
public static class HelloWorldSuperSuper { | ||
|
||
protected void main() { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
public static class HelloWorldSuper extends HelloWorldSuperSuper { | ||
|
||
private void main(String[] args) { | ||
System.out.println("Private Instance World"); | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...ployment/src/test/java/io/quarkus/commandmode/launch/InstanceMainCommandModeTestCase.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,34 @@ | ||
package io.quarkus.commandmode.launch; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class InstanceMainCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
void main(String[] args) { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
.../test/java/io/quarkus/commandmode/launch/InstanceMainInSuperClassCommandModeTestCase.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,45 @@ | ||
package io.quarkus.commandmode.launch; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class InstanceMainInSuperClassCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldSuperSuper.class, HelloWorldSuper.class, HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain extends HelloWorldSuper { | ||
|
||
} | ||
|
||
public static class HelloWorldSuperSuper { | ||
|
||
protected void main() { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
public static class HelloWorldSuper extends HelloWorldSuperSuper { | ||
|
||
protected void main2() { | ||
System.out.println("Hello"); | ||
} | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...java/io/quarkus/commandmode/launch/InstanceMainInSuperClassNoArgsCommandModeTestCase.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,46 @@ | ||
package io.quarkus.commandmode.launch; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class InstanceMainInSuperClassNoArgsCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldSuper.class, HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain extends HelloWorldSuper { | ||
|
||
} | ||
|
||
public static class HelloWorldSuper { | ||
|
||
void main() { | ||
System.out.println("Hello World"); | ||
} | ||
|
||
void main2() { | ||
System.out.println("Hello"); | ||
} | ||
|
||
void main3(String[] args) { | ||
System.out.println("Hello"); | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...nt/src/test/java/io/quarkus/commandmode/launch/InstanceMainNoArgsCommandModeTestCase.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,34 @@ | ||
package io.quarkus.commandmode.launch; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class InstanceMainNoArgsCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
void main() { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...test/java/io/quarkus/commandmode/launch/MixWithAndWithoutArgsMainCommandModeTestCase.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,38 @@ | ||
package io.quarkus.commandmode.launch; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class MixWithAndWithoutArgsMainCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
static void main(String[] args) { | ||
System.out.println("Hello World"); | ||
} | ||
|
||
void main() { | ||
System.out.println("Hi World"); | ||
} | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...va/io/quarkus/commandmode/launch/MultipleInstanceMainInSuperClassCommandModeTestCase.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,49 @@ | ||
package io.quarkus.commandmode.launch; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class MultipleInstanceMainInSuperClassCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldSuperSuper.class, HelloWorldSuper.class, HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hi World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain extends HelloWorldSuper { | ||
|
||
} | ||
|
||
public static class HelloWorldSuperSuper { | ||
|
||
protected void main(String[] args) { | ||
System.out.println("Hi World"); | ||
} | ||
|
||
protected void main() { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
public static class HelloWorldSuper extends HelloWorldSuperSuper { | ||
|
||
protected void main2() { | ||
System.out.println("Hello"); | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...t/src/test/java/io/quarkus/commandmode/launch/NonPublicStaticMainCommandModeTestCase.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,34 @@ | ||
package io.quarkus.commandmode.launch; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class NonPublicStaticMainCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectExit(true) | ||
.setRun(true); | ||
|
||
@Test | ||
public void testRun() { | ||
Assertions.assertThat(config.getStartupConsoleOutput()).contains("Hello World"); | ||
Assertions.assertThat(config.getExitCode()).isEqualTo(0); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...ent/src/test/java/io/quarkus/commandmode/launch/PrivateStaticMainCommandModeTestCase.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,33 @@ | ||
package io.quarkus.commandmode.launch; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class PrivateStaticMainCommandModeTestCase { | ||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HelloWorldMain.class)) | ||
.setApplicationName("run-exit") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.setExpectedException(RuntimeException.class); | ||
|
||
@Test | ||
public void shouldNeverRun() { | ||
fail(); | ||
} | ||
|
||
@QuarkusMain | ||
public static class HelloWorldMain { | ||
|
||
private static void main(String[] args) { | ||
System.out.println("Hello World"); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.