diff --git a/tests/spread/rockcraft/plugin-jlink/bare-build-2404/rockcraft.yaml b/tests/spread/rockcraft/plugin-jlink/bare-build-2404/rockcraft.yaml new file mode 100644 index 000000000..f5d7e5b13 --- /dev/null +++ b/tests/spread/rockcraft/plugin-jlink/bare-build-2404/rockcraft.yaml @@ -0,0 +1,5 @@ +name: bare-build-2004 +base: bare +build-base: ubuntu@20.04 + +# Remaining contents will come from "parts.yaml" diff --git a/tests/spread/rockcraft/plugin-jlink/base-2404/rockcraft.yaml b/tests/spread/rockcraft/plugin-jlink/base-2404/rockcraft.yaml new file mode 100644 index 000000000..7e89daebd --- /dev/null +++ b/tests/spread/rockcraft/plugin-jlink/base-2404/rockcraft.yaml @@ -0,0 +1,4 @@ +name: base-2404 +base: ubuntu@24.04 + +# Remaining contents will come from "parts.yaml" diff --git a/tests/spread/rockcraft/plugin-jlink/helloworld/pom.xml b/tests/spread/rockcraft/plugin-jlink/helloworld/pom.xml new file mode 100644 index 000000000..fda0a4cb9 --- /dev/null +++ b/tests/spread/rockcraft/plugin-jlink/helloworld/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + com.yourcompany + helloworld + 1.0-SNAPSHOT + + helloworld + + http://www.example.com + + + UTF-8 + + + + + junit + junit + 4.11 + test + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/tests/spread/rockcraft/plugin-jlink/helloworld/src/main/java/com/yourcompany/helloworld/App.java b/tests/spread/rockcraft/plugin-jlink/helloworld/src/main/java/com/yourcompany/helloworld/App.java new file mode 100644 index 000000000..f39741d1f --- /dev/null +++ b/tests/spread/rockcraft/plugin-jlink/helloworld/src/main/java/com/yourcompany/helloworld/App.java @@ -0,0 +1,13 @@ +package com.yourcompany.helloworld; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/tests/spread/rockcraft/plugin-jlink/helloworld/src/test/java/com/yourcompany/helloworld/AppTest.java b/tests/spread/rockcraft/plugin-jlink/helloworld/src/test/java/com/yourcompany/helloworld/AppTest.java new file mode 100644 index 000000000..d38f3be35 --- /dev/null +++ b/tests/spread/rockcraft/plugin-jlink/helloworld/src/test/java/com/yourcompany/helloworld/AppTest.java @@ -0,0 +1,20 @@ +package com.yourcompany.helloworld; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +} diff --git a/tests/spread/rockcraft/plugin-jlink/parts.yaml b/tests/spread/rockcraft/plugin-jlink/parts.yaml new file mode 100644 index 000000000..feb12ab44 --- /dev/null +++ b/tests/spread/rockcraft/plugin-jlink/parts.yaml @@ -0,0 +1,49 @@ + +# Actual parts definition for the rockcraft + python cases that we are testing. +# (this gets appended to all rockcraft.yaml files in the subdirectories in the +# main task.yaml). + +version: '0.1' +summary: A rock that bundles a Java project. +description: A rock that bundles a Java project. +license: GPL-3.0 +platforms: + amd64: + +parts: + helloworld: + source: helloworld + source-type: local + build-packages: + - openjdk-21-jdk + - maven + plugin: nil + build-environment: + - JAVA_HOME: "/usr/lib/jvm/java-21-openjdk-${CRAFT_TARGET_ARCH}" + override-build: | + mvn package + mkdir -p ${CRAFT_PART_INSTALL}/jars + cp ${CRAFT_PART_BUILD}/target/*.jar ${CRAFT_PART_INSTALL}/jars + craftctl default + + deps: + plugin: nil + source: https://github.com/vpa1977/chisel-releases + source-type: git + source-branch: 24.04-openjdk-21-jre-headless + override-build: | + chisel cut --release ./ --root ${CRAFT_PART_INSTALL} libc6_libs \ + libgcc-s1_libs \ + libstdc++6_libs \ + zlib1g_libs \ + libnss3_libs \ + base-files_base + craftctl default + + runtime: + after: + - helloworld + - deps + plugin: jlink + jlink-jars: + - jars/helloworld-1.0-SNAPSHOT.jar diff --git a/tests/spread/rockcraft/plugin-jlink/task.yaml b/tests/spread/rockcraft/plugin-jlink/task.yaml new file mode 100644 index 000000000..dfd2c3795 --- /dev/null +++ b/tests/spread/rockcraft/plugin-jlink/task.yaml @@ -0,0 +1,29 @@ +summary: JLink plugin tests +environment: + SCENARIO/base_2404: base-2404 + SCENARIO/bare_build_2004: bare-build-2404 +execute: | + SCENARIO_DIR="${SCENARIO}" + ROCK_FILE="${SCENARIO}_0.1_amd64.rock" + IMAGE="${SCENARIO}:0.1" + + # change into the scenario's directory + cd ${SCENARIO_DIR} + + # add the parts definition, common to all scenarios + cat ../parts.yaml >> rockcraft.yaml + + # copy the source of the project we're building (also shared) + cp -r ../helloworld . + + # Build the rock & load it into docker + run_rockcraft pack + test -f ${ROCK_FILE} + sudo rockcraft.skopeo --insecure-policy copy oci-archive:${ROCK_FILE} docker-daemon:${IMAGE} + docker images + rm ${ROCK_FILE} + + # Run the packaged project + docker run --rm $IMAGE exec /usr/bin/java -jar jars/helloworld-1.0-SNAPSHOT.jar | MATCH "Hello World!" + + docker system prune -a -f