mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Java: Add test for multi-module projects with different Java versions
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>maven-multimodule-test-java-version</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<artifactId>main-module</artifactId>
|
||||
</project>
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.example;
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>maven-multimodule-test-java-version</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.release>17</maven.compiler.release>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>main-module</module>
|
||||
<module>test-module</module>
|
||||
</modules>
|
||||
</project>
|
||||
@@ -0,0 +1,7 @@
|
||||
main-module/pom.xml
|
||||
main-module/src/main/java/com/example/App.java
|
||||
main-module/target/maven-archiver/pom.properties
|
||||
pom.xml
|
||||
test-module/pom.xml
|
||||
test-module/src/main/java/com/example/tests/TestUtils.java
|
||||
test-module/target/maven-archiver/pom.properties
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>maven-multimodule-test-java-version</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<artifactId>test-module</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.release>21</maven.compiler.release>
|
||||
</properties>
|
||||
</project>
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.tests;
|
||||
|
||||
// Requires Java 21: switch with pattern matching and guards
|
||||
public class TestUtils {
|
||||
public static String analyze(Object obj) {
|
||||
return switch (obj) {
|
||||
case String s when s.length() > 5 -> "long";
|
||||
case String s -> "short";
|
||||
default -> "other";
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
def test(codeql, java):
|
||||
codeql.database.create()
|
||||
Reference in New Issue
Block a user