Skip to content

Commit 012dfa2

Browse files
committed
Java: Add test for multi-module projects with different Java versions
1 parent aa3000d commit 012dfa2

File tree

7 files changed

+69
-0
lines changed

7 files changed

+69
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>com.example</groupId>
6+
<artifactId>maven-multimodule-test-java-version</artifactId>
7+
<version>1.0</version>
8+
</parent>
9+
<artifactId>main-module</artifactId>
10+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example;
2+
3+
public class App {
4+
public static void main(String[] args) {
5+
System.out.println("Hello World!");
6+
}
7+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.example</groupId>
5+
<artifactId>maven-multimodule-test-java-version</artifactId>
6+
<version>1.0</version>
7+
<packaging>pom</packaging>
8+
9+
<properties>
10+
<maven.compiler.release>17</maven.compiler.release>
11+
</properties>
12+
13+
<modules>
14+
<module>main-module</module>
15+
<module>test-module</module>
16+
</modules>
17+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
main-module/pom.xml
2+
main-module/src/main/java/com/example/App.java
3+
main-module/target/maven-archiver/pom.properties
4+
pom.xml
5+
test-module/pom.xml
6+
test-module/src/main/java/com/example/tests/TestUtils.java
7+
test-module/target/maven-archiver/pom.properties
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>com.example</groupId>
6+
<artifactId>maven-multimodule-test-java-version</artifactId>
7+
<version>1.0</version>
8+
</parent>
9+
<artifactId>test-module</artifactId>
10+
11+
<properties>
12+
<maven.compiler.release>21</maven.compiler.release>
13+
</properties>
14+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.example.tests;
2+
3+
// Requires Java 21: switch with pattern matching and guards
4+
public class TestUtils {
5+
public static String analyze(Object obj) {
6+
return switch (obj) {
7+
case String s when s.length() > 5 -> "long";
8+
case String s -> "short";
9+
default -> "other";
10+
};
11+
}
12+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test(codeql, java):
2+
codeql.database.create()

0 commit comments

Comments
 (0)