Skip to content

Commit

Permalink
Externaliza gradle/maven command
Browse files Browse the repository at this point in the history
  • Loading branch information
glefloch committed Oct 14, 2020
1 parent 8304773 commit 97663c6
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ language:
id: io.quarkus
buildtool:
build-dir: build
cli: gradle
guide: https://quarkus.io/guides/gradle-tooling
guide-native: https://quarkus.io/guides/gradle-tooling#building-a-native-executable
cmd:
dev: gradle quarkusDev
package: gradle quarkusBuild
package-uberjar: gradle quarkusBuild --uber-jar
package-native: gradle build -Dquarkus.package.type=native
package-native-container: gradle build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
build-ci: gradle build
dev: quarkusDev
package: quarkusBuild
package-uberjar: quarkusBuild --uber-jar
package-native: build -Dquarkus.package.type=native
package-native-container: build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
build-ci: build
kotlin:
dependencies:
- org.jetbrains.kotlin:kotlin-stdlib-jdk8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ language:
id: io.quarkus
buildtool:
build-dir: build
cli: gradle
guide: https://quarkus.io/guides/gradle-tooling
guide-native: https://quarkus.io/guides/gradle-tooling#building-a-native-executable
cmd:
dev: gradle quarkusDev
package: gradle quarkusBuild
package-uberjar: gradle quarkusBuild --uber-jar
package-native: gradle build -Dquarkus.package.type=native
package-native-container: gradle build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
build-ci: gradle build
dev: quarkusDev
package: quarkusBuild
package-uberjar: quarkusBuild --uber-jar
package-native: build -Dquarkus.package.type=native
package-native-container: build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
build-ci: build
kotlin:
dependencies:
- org.jetbrains.kotlin:kotlin-stdlib-jdk8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ language:
shared-data:
buildtool:
build-dir: target
cli: mvn
guide: https://quarkus.io/guides/maven-tooling.html
guide-native: https://quarkus.io/guides/building-native-image
cmd:
dev: mvn compile quarkus:dev
package: mvn package
package-uberjar: mvn package -PuberJar
package-native: mvn package -Pnative
package-native-container: mvn package -Pnative -Dquarkus.native.container-build=true
build-ci: mvn verify -B
dev: compile quarkus:dev
package: package
package-uberjar: package -PuberJar
package-native: package -Pnative
package-native-container: package -Pnative -Dquarkus.native.container-build=true
build-ci: verify -B
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h2>Why do you see this?</h2>

<h2>What can I do from here?</h2>

<p>If not already done, run the application in <em>dev mode</em> using: <code>{buildtool.cmd.dev}</code>.
<p>If not already done, run the application in <em>dev mode</em> using: <code>{buildtool.cli} {buildtool.cmd.dev}</code>.
</p>
<ul>
<li>Open the example <a href="{resource.path}" target="_blank">"/hello"</a> endpoint</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h2>Why do you see this?</h2>

<h2>What can I do from here?</h2>

<p>If not already done, run the application in <em>dev mode</em> using: <code>{buildtool.cmd.dev}</code>.
<p>If not already done, run the application in <em>dev mode</em> using: <code>{buildtool.cli} {buildtool.cmd.dev}</code>.
</p>
<ul>
<li>Open the example <a href="{resource.path}" target="_blank">"/hello"</a> endpoint</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ If you want to learn more about Quarkus, please visit its website: https://quark

You can run your application in dev mode that enables live coding using:
```shell script
{buildtool.cmd.dev}
{buildtool.cli} {buildtool.cmd.dev}
```

## Packaging and running the application

The application can be packaged using:
```shell script
{buildtool.cmd.package}
{buildtool.cli} {buildtool.cmd.package}
```
It produces the `{project.artifact-id}-{project.version}-runner.jar` file in the `/{buildtool.build-dir}` directory.
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `{buildtool.build-dir}/lib` directory.
If you want to build an _über-jar_, just add the `--uber-jar` option to the command line:
```shell script
{buildtool.cmd.package-uberjar}
{buildtool.cli} {buildtool.cmd.package-uberjar}
```

The application is now runnable using `java -jar {buildtool.build-dir}/{project.artifact-id}-{project.version}-runner.jar`.
Expand All @@ -30,12 +30,12 @@ The application is now runnable using `java -jar {buildtool.build-dir}/{project.

You can create a native executable using:
```shell script
{buildtool.cmd.package-native}
{buildtool.cli} {buildtool.cmd.package-native}
```

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
```shell script
{buildtool.cmd.package-native-container}
{buildtool.cli} {buildtool.cmd.package-native-container}
```

You can then execute your native executable with: `./{buildtool.build-dir}/{project.artifact-id}-{project.version}-runner`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ jobs:
with:
java-version: {java.version}
- name: Build
run: {buildtool.cmd.build-ci}
{#if buildtool.cli == 'gradle'}
uses: eskatos/gradle-command-action@v1
with:
arguments: {buildtool.cmd.build-ci}
{#else}
run: {buildtool.cli} {buildtool.cmd.build-ci}
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@ language:
version: 6.5.1
shared-data:
buildtool:
cmd:
dev: ./gradlew quarkusDev
package: ./gradlew quarkusBuild
package-uberjar: ./gradlew quarkusBuild --uber-jar
package-native: ./gradlew build -Dquarkus.package.type=native
package-native-container: ./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
build-ci: ./gradlew build
cli: ./gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,4 @@ language:
wrapper-version: 0.5.6
shared-data:
buildtool:
cmd:
dev: ./mvnw compile quarkus:dev
package: ./mvnw package
package-uberjar: ./mvnw package -PuberJar
package-native: ./mvnw package -Pnative
package-native-container: ./mvnw package -Pnative -Dquarkus.native.container-build=true
build-ci: ./mvnw verify -B
cli: ./mvnw
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public enum DataKey {
NO_BUILD_TOOL_WRAPPER("quarkus-project.no-build-tool-wrapper"),
NO_DOCKERFILES("quarkus-project.no-dockerfiles");

;

private final String key;

DataKey(String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
Expand Down Expand Up @@ -428,6 +429,44 @@ void generateCodestartProjectQute() throws IOException {
assertThat(projectDir.resolve("src/main/java/org/acme/qute/Item.java")).exists();
}

@Test
public void generateGradleWrapperGithubAction() throws Exception {
final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder()
.buildTool(BuildTool.GRADLE)
.addData(getTestInputData())
.addCodestarts(Collections.singletonList("github-action"))
.putData(QuarkusCodestartData.DataKey.JAVA_VERSION.getKey(), System.getProperty("java.specification.version"))
.build();
Path projectDir = testDirPath.resolve("gradle-github");
getCatalog().createProject(input).generate(projectDir);

checkGradle(projectDir);

assertThat(projectDir.resolve(".github/workflows/ci.yml"))
.exists()
.satisfies(checkContains("run: ./gradlew build"));
}

@Test
public void generateGradleNoWrapperGithubAction() throws Exception {
final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder()
.buildTool(BuildTool.GRADLE)
.noBuildToolWrapper()
.addData(getTestInputData())
.addCodestarts(Collections.singletonList("github-action"))
.putData(QuarkusCodestartData.DataKey.JAVA_VERSION.getKey(), System.getProperty("java.specification.version"))
.build();
Path projectDir = testDirPath.resolve("gradle-nowrapper-github");
getCatalog().createProject(input).generate(projectDir);

checkGradle(projectDir);

assertThat(projectDir.resolve(".github/workflows/ci.yml"))
.exists()
.satisfies(checkContains("uses: eskatos/gradle-command-action@v1"))
.satisfies(checkContains("arguments: build"));
}

private void checkNoExample(Path projectDir) {
assertThat(projectDir.resolve("src/main/java")).doesNotExist();
assertThat(projectDir.resolve("src/main/kotlin")).doesNotExist();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ private void generateProjectRunTests(String buildToolName, String language, List
final CodestartProjectDefinition projectDefinition = getCatalog().createProject(input);
Path projectDir = testDirPath.resolve(name);
projectDefinition.generate(projectDir);

final int result = WrapperRunner.run(projectDir,
WrapperRunner.Wrapper.fromBuildtool(buildToolName));
assertThat(result).isZero();
Expand Down

0 comments on commit 97663c6

Please sign in to comment.