Skip to content

Commit c751827

Browse files
committed
Add maven test
1 parent a6e8484 commit c751827

File tree

8 files changed

+656
-2
lines changed

8 files changed

+656
-2
lines changed

.github/workflows/integration.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
- name: Run gradle integration tests
1919
working-directory: integration/gradle
2020
run: ./testMacos.sh
21-
# TODO: Add maven integration tests
21+
- name: Run maven integration tests
22+
working-directory: integration/maven
23+
run: ./testMacos.sh
2224
# TODO windows
2325
# TODO linux

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies {
4141
implementation 'org.codehaus.plexus:plexus-utils:3.5.1'
4242
implementation 'org.twdata.maven:mojo-executor:2.3.0'
4343
implementation 'commons-io:commons-io:2.16.1'
44-
implementation 'org.apache.commons:commons-lang3:3.9'
44+
implementation 'org.apache.commons:commons-lang3:3.20.0'
4545
implementation 'org.apache.commons:commons-collections4:4.3'
4646
implementation 'org.apache.commons:commons-compress:1.21'
4747
implementation 'org.apache.velocity:velocity-engine-core:2.3'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip

integration/maven/app/pom.xml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<groupId>org.example</groupId>
9+
<artifactId>javapackagerdemo</artifactId>
10+
<version>1.0.0-SNAPSHOT</version>
11+
<packaging>jar</packaging>
12+
13+
<name>JavaPackager Demo</name>
14+
<description>Demo application for JavaPackager Maven integration</description>
15+
16+
<properties>
17+
<maven.compiler.source>21</maven.compiler.source>
18+
<maven.compiler.target>21</maven.compiler.target>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
</properties>
21+
22+
<dependencies>
23+
<!-- Include a dependency to ensure that dependency packaging works correctly -->
24+
<dependency>
25+
<groupId>org.apache.commons</groupId>
26+
<artifactId>commons-lang3</artifactId>
27+
<version>3.20.0</version>
28+
</dependency>
29+
</dependencies>
30+
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<groupId>org.apache.maven.plugins</groupId>
35+
<artifactId>maven-compiler-plugin</artifactId>
36+
<version>3.11.0</version>
37+
<configuration>
38+
<source>21</source>
39+
<target>21</target>
40+
</configuration>
41+
</plugin>
42+
43+
<plugin>
44+
<groupId>org.apache.maven.plugins</groupId>
45+
<artifactId>maven-jar-plugin</artifactId>
46+
<version>3.3.0</version>
47+
<configuration>
48+
<archive>
49+
<manifest>
50+
<mainClass>org.example.App</mainClass>
51+
</manifest>
52+
</archive>
53+
</configuration>
54+
</plugin>
55+
56+
<!-- JavaPackager Maven Plugin - Mac packaging task -->
57+
<plugin>
58+
<groupId>io.github.fvarrui</groupId>
59+
<artifactId>javapackager</artifactId>
60+
<version>1.7.7-SNAPSHOT</version>
61+
<executions>
62+
<execution>
63+
<phase>package</phase>
64+
<goals>
65+
<goal>package</goal>
66+
</goals>
67+
<id>packageForMac</id>
68+
<configuration>
69+
<mainClass>org.example.App</mainClass>
70+
<bundleJre>true</bundleJre>
71+
<generateInstaller>true</generateInstaller>
72+
<administratorRequired>false</administratorRequired>
73+
<platform>mac</platform>
74+
<macConfig>
75+
<appId>org.example.javapackagerdemo</appId>
76+
<generateDmg>true</generateDmg>
77+
<generatePkg>true</generatePkg>
78+
<macStartup>UNIVERSAL</macStartup>
79+
</macConfig>
80+
</configuration>
81+
</execution>
82+
</executions>
83+
</plugin>
84+
</plugins>
85+
</build>
86+
87+
</project>
88+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.example;
2+
3+
import org.apache.commons.lang3.SystemUtils;
4+
5+
import java.io.IOException;
6+
import java.nio.file.Files;
7+
import java.nio.file.Path;
8+
9+
public class App {
10+
public static void main(String[] args) throws IOException {
11+
String targetDir;
12+
// Use hardcoded directories to make the test script simple. This may not run correctly on all systems, as long
13+
// as it runs correctly on the github actions runners it is good enough
14+
if(SystemUtils.IS_OS_WINDOWS) {
15+
targetDir = "C:\\Windows\\Temp";
16+
} else if(SystemUtils.IS_OS_LINUX) {
17+
targetDir = "/tmp";
18+
} else if(SystemUtils.IS_OS_MAC) {
19+
targetDir = "/tmp";
20+
} else {
21+
throw new RuntimeException("Unsupported OS");
22+
}
23+
Path targetFile = Path.of(targetDir, "javapackager-testfile.txt");
24+
Files.write(targetFile, Long.toString(System.currentTimeMillis()).getBytes());
25+
}
26+
}

0 commit comments

Comments
 (0)