examples/development/java/README.md
Maven is an all-in-one CI-CD tool for building testing and deploying Java projects. To setup a sample project with Java and Maven in devbox follow the steps below:
dummy/ and call devbox init inside it. Then add the nix-pkg: devbox add jdk and devbox add maven.
jdk with the version of JDK you want. Get the exact nix-pkg name from search.nixos.org.devbox shell to get a shell with that jdk nix pkg.mvn archetype:generate -DgroupId=com.devbox.mavenapp -DartifactId=devbox-maven-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
pom.xml file, replace java version in <maven.compiler.source> with the specific version you are testing for.mvn package should compile the package and create a target/ directory.java -cp target/devbox-maven-app-1.0-SNAPSHOT.jar com.devbox.mavenapp.App should print "Hello World!".target/ to .gitignore.To test a sample Gradle app with devbox, follow the steps below:
dummy/ and call devbox init inside it. Then add these packages: devbox add jdk and devbox add gradle.
jdk with the version of JDK you want. Get the exact nix-pkg name from search.nixos.org.devbox shell to get a shell with that jdk nix pkg.gradle init
gradle.build file, put the following text block:
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = 17
targetCompatibility = 17
mainClassName = 'hello.HelloWorld'
jar {
manifest {
attributes 'Main-Class': 'hello.HelloWorld'
}
}
gradle build should compile the package and create a build/ directory that contains an executable jar file.gradle run should print "Hello World!".build/ to .gitignore.