Idea: java build
within a maven / gradle project root should detect and run build tool automatically with "appropriate" settings.
Running java build
within a maven project root should execute mvn clean verify
by default (maven BCP).
Example command
tom@neumann ~/dev/repos/gh/thomasdarimont/training/java-workbench/lib-java-build-tool (master)
$ java --enable-preview --source=20 -cp target/classes build.java clean package
if this were explicitly supported by the java launcher, we could have something like the following to produce the output below:
$ java build
This would still give users the choice of their build tool but invoking it could be build-tool agnostic.
Example Output
build: Found maven project
build: Maven start
[INFO] Scanning for projects...
[INFO]
[INFO] -------< com.github.thomasdarimont.training:lib-java-build-tool >-------
[INFO] Building lib-java-build-tool 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ lib-java-build-tool ---
[INFO] Deleting /home/tom/dev/repos/gh/thomasdarimont/training/java-workbench/lib-java-build-tool/target
[INFO]
[INFO] --- toolchains:3.1.0:toolchain (default) @ lib-java-build-tool ---
[INFO] Required toolchain: jdk [ os='Linux' vendor='OpenJDK' version='20-open' ]
[INFO] Found matching toolchain for type jdk: JDK[/home/tom/.sdkman/candidates/java/20.ea.20-open]
[INFO]
[INFO] --- resources:3.3.0:resources (default-resources) @ lib-java-build-tool ---
[INFO] Copying 0 resource
[INFO]
[INFO] --- compiler:3.8.1:compile (default-compile) @ lib-java-build-tool ---
[INFO] Toolchain in maven-compiler-plugin: JDK[/home/tom/.sdkman/candidates/java/20.ea.20-open]
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /home/tom/dev/repos/gh/thomasdarimont/training/java-workbench/lib-java-build-tool/target/classes
[INFO]
[INFO] --- resources:3.3.0:testResources (default-testResources) @ lib-java-build-tool ---
[INFO] skip non existing resourceDirectory /home/tom/dev/repos/gh/thomasdarimont/training/java-workbench/lib-java-build-tool/src/test/resources
[INFO]
[INFO] --- compiler:3.8.1:testCompile (default-testCompile) @ lib-java-build-tool ---
[INFO] Toolchain in maven-compiler-plugin: JDK[/home/tom/.sdkman/candidates/java/20.ea.20-open]
[INFO] Changes detected - recompiling the module!
[INFO]
[INFO] --- surefire:2.22.2:test (default-test) @ lib-java-build-tool ---
[INFO] Toolchain in maven-surefire-plugin: JDK[/home/tom/.sdkman/candidates/java/20.ea.20-open]
[INFO]
[INFO] --- jar:3.3.0:jar (default-jar) @ lib-java-build-tool ---
[INFO] Building jar: /home/tom/dev/repos/gh/thomasdarimont/training/java-workbench/lib-java-build-tool/target/lib-java-build-tool-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.509 s
[INFO] Finished at: 2023-03-21T15:40:33+01:00
[INFO] ------------------------------------------------------------------------
build: Maven end