-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Java: Add test for multi-module projects with different Java versions #20615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6b890ea
Java: Add test for multi-module projects with different Java versions
IdrissRio 5247c88
Java: Add test for pom targeting Java 8 but rquiring Java 11
IdrissRio fcc54c1
Java: Add test for detecting `--add-exports` in poms
IdrissRio 7dab2be
Java: Add test for Java 16 target when only Java 17+ is available
IdrissRio a82b5e7
Java: Add test for selecting the highest compiler release in a pom
IdrissRio 3b7f2f4
Java: Add `LGTM_INDEX_ MAVEN_TOLLCHAINS_FILE` for new Maven integrat…
IdrissRio e6d4e51
Java: Add change note for Maven Java version auto-detection
IdrissRio d916ebd
Java: Address review comments. Improve Change note
IdrissRio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
java/ql/integration-tests/java/maven-add-exports-module-flags/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.example</groupId> | ||
| <artifactId>maven-add-exports-module-flags</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
|
|
||
| <name>maven-add-exports-module-flags</name> | ||
| <description>Test case: Project using --add-exports. Autobuilder should detect this and use --source/--target.</description> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <java.version>11</java.version> | ||
| </properties> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.11.0</version> | ||
| <configuration> | ||
| <source>${java.version}</source> | ||
| <target>${java.version}</target> | ||
| <compilerArgs> | ||
| <arg>--add-exports</arg> | ||
| <arg>jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg> | ||
| <arg>--add-exports</arg> | ||
| <arg>jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg> | ||
| <arg>--add-exports</arg> | ||
| <arg>jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg> | ||
| <arg>--add-exports</arg> | ||
| <arg>jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg> | ||
| </compilerArgs> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
3 changes: 3 additions & 0 deletions
3
java/ql/integration-tests/java/maven-add-exports-module-flags/source_archive.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| pom.xml | ||
| src/main/java/com/example/CompilerUser.java | ||
| target/maven-archiver/pom.properties |
15 changes: 15 additions & 0 deletions
15
...ion-tests/java/maven-add-exports-module-flags/src/main/java/com/example/CompilerUser.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.example; | ||
|
|
||
| import com.sun.tools.javac.api.JavacTool; | ||
|
|
||
| /** | ||
| * Simple class that uses JDK compiler internals. | ||
| * This requires --add-exports flags to compile. | ||
| */ | ||
| public class CompilerUser { | ||
| public static void main(String[] args) { | ||
| // Use JavacTool from jdk.compiler module | ||
| JavacTool tool = JavacTool.create(); | ||
| System.out.println("Compiler tool: " + tool.getClass().getName()); | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
java/ql/integration-tests/java/maven-add-exports-module-flags/test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| def test(codeql, java, actions_toolchains_file): | ||
| codeql.database.create(_env={"LGTM_INDEX_MAVEN_TOOLCHAINS_FILE": str(actions_toolchains_file)}) |
51 changes: 51 additions & 0 deletions
51
java/ql/integration-tests/java/maven-execution-specific-java-version/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.example</groupId> | ||
| <artifactId>maven-execution-specific-java-version</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
|
|
||
| <name>maven-execution-specific-java-version</name> | ||
| <description>Test case: Project with execution-specific Java versions (Java 11 for main, Java 17 for test). Maven.java should detect the highest version (17) and use it for compilation.</description> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| </properties> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.13.0</version> | ||
| <executions> | ||
| <!-- Compilation for src/main/java --> | ||
| <execution> | ||
| <id>default-compile</id> | ||
| <phase>compile</phase> | ||
| <goals> | ||
| <goal>compile</goal> | ||
| </goals> | ||
| <configuration> | ||
| <release>11</release> <!-- Java 11 for main --> | ||
| </configuration> | ||
| </execution> | ||
|
|
||
| <!-- Compilation for src/test/java --> | ||
| <execution> | ||
| <id>default-testCompile</id> | ||
| <phase>test-compile</phase> | ||
| <goals> | ||
| <goal>testCompile</goal> | ||
| </goals> | ||
| <configuration> | ||
| <release>17</release> <!-- Java 17 for test --> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
4 changes: 4 additions & 0 deletions
4
java/ql/integration-tests/java/maven-execution-specific-java-version/source_archive.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| pom.xml | ||
| src/main/java/com/example/App.java | ||
| src/test/java/com/example/AppTest.java | ||
| target/maven-archiver/pom.properties |
12 changes: 12 additions & 0 deletions
12
...ation-tests/java/maven-execution-specific-java-version/src/main/java/com/example/App.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.example; | ||
|
|
||
| public class App { | ||
| public static void main(String[] args) { | ||
| var message = "Hello World! Running on Java " + System.getProperty("java.version"); | ||
| System.out.println(message); | ||
| } | ||
|
|
||
| public String getMessage() { | ||
| return "Hello from App"; | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
...n-tests/java/maven-execution-specific-java-version/src/test/java/com/example/AppTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.example; | ||
|
|
||
| public class AppTest { | ||
| public static void main(String[] args) { | ||
| var text = """ | ||
| Hello | ||
| World | ||
| """; | ||
| System.out.println(text.strip()); | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
java/ql/integration-tests/java/maven-execution-specific-java-version/test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| def test(codeql, java, actions_toolchains_file): | ||
| codeql.database.create(_env={"LGTM_INDEX_MAVEN_TOOLCHAINS_FILE": str(actions_toolchains_file)}) |
30 changes: 30 additions & 0 deletions
30
java/ql/integration-tests/java/maven-java16-with-higher-jdk/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.example</groupId> | ||
| <artifactId>maven-java16-with-higher-jdk</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
|
|
||
| <name>maven-java16-with-higher-jdk</name> | ||
| <description>Test case: Java 16 target when only Java 17+ is available.</description> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <java.version>16</java.version> | ||
| </properties> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.11.0</version> | ||
| <configuration> | ||
| <release>${java.version}</release> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
3 changes: 3 additions & 0 deletions
3
java/ql/integration-tests/java/maven-java16-with-higher-jdk/source_archive.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| pom.xml | ||
| src/main/java/com/example/App.java | ||
| target/maven-archiver/pom.properties |
15 changes: 15 additions & 0 deletions
15
...ql/integration-tests/java/maven-java16-with-higher-jdk/src/main/java/com/example/App.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.example; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Simple class using Java 16 features (e.g.,records). | ||
| */ | ||
| public class App { | ||
| public static void main(String[] args) { | ||
| Person person = new Person("Bob", 42); | ||
| System.out.println(person); | ||
| } | ||
| } | ||
|
|
||
| record Person(String name, int age) {} | ||
2 changes: 2 additions & 0 deletions
2
java/ql/integration-tests/java/maven-java16-with-higher-jdk/test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| def test(codeql, java, actions_toolchains_file): | ||
| codeql.database.create(_env={"LGTM_INDEX_MAVEN_TOOLCHAINS_FILE": str(actions_toolchains_file)}) |
41 changes: 41 additions & 0 deletions
41
java/ql/integration-tests/java/maven-java8-java11-dependency/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.example</groupId> | ||
| <artifactId>maven-java8-java11-dependency</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
|
|
||
| <name>maven-java8-java11-dependency</name> | ||
| <description>Test case: Java 8 project with dependency requiring Java 11+</description> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <maven.compiler.source>1.8</maven.compiler.source> | ||
| <maven.compiler.target>1.8</maven.compiler.target> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <!-- TestNG 7.7.0 is compiled with Java 11 (class file version 55.0) --> | ||
| <dependency> | ||
| <groupId>org.testng</groupId> | ||
| <artifactId>testng</artifactId> | ||
| <version>7.7.0</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.8.0</version> | ||
| </plugin> | ||
| <plugin> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>2.22.1</version> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
4 changes: 4 additions & 0 deletions
4
java/ql/integration-tests/java/maven-java8-java11-dependency/source_archive.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| pom.xml | ||
| src/main/java/com/example/Calculator.java | ||
| src/test/java/com/example/CalculatorTest.java | ||
| target/maven-archiver/pom.properties |
11 changes: 11 additions & 0 deletions
11
...ration-tests/java/maven-java8-java11-dependency/src/main/java/com/example/Calculator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.example; | ||
|
|
||
| public class Calculator { | ||
| public int add(int a, int b) { | ||
| return a + b; | ||
| } | ||
|
|
||
| public int multiply(int a, int b) { | ||
| return a * b; | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
...on-tests/java/maven-java8-java11-dependency/src/test/java/com/example/CalculatorTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.example; | ||
|
|
||
| import org.testng.Assert; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| /** | ||
| * Test class using TestNG 7.7.0 which requires Java 11+. | ||
| */ | ||
| public class CalculatorTest { | ||
| @Test | ||
| public void testAdd() { | ||
| Calculator calc = new Calculator(); | ||
| Assert.assertEquals(calc.add(2, 3), 5); | ||
| } | ||
|
|
||
| @Test | ||
| public void testMultiply() { | ||
| Calculator calc = new Calculator(); | ||
| Assert.assertEquals(calc.multiply(3, 4), 12); | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
java/ql/integration-tests/java/maven-java8-java11-dependency/test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| def test(codeql, java, actions_toolchains_file): | ||
| codeql.database.create(_env={"LGTM_INDEX_MAVEN_TOOLCHAINS_FILE": str(actions_toolchains_file)}) |
10 changes: 10 additions & 0 deletions
10
java/ql/integration-tests/java/maven-multimodule-test-java-version/main-module/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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> |
7 changes: 7 additions & 0 deletions
7
...s/java/maven-multimodule-test-java-version/main-module/src/main/java/com/example/App.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.example; | ||
|
|
||
| public class App { | ||
| public static void main(String[] args) { | ||
| System.out.println("Hello World!"); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
java/ql/integration-tests/java/maven-multimodule-test-java-version/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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> |
7 changes: 7 additions & 0 deletions
7
java/ql/integration-tests/java/maven-multimodule-test-java-version/source_archive.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
14 changes: 14 additions & 0 deletions
14
java/ql/integration-tests/java/maven-multimodule-test-java-version/test-module/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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> |
12 changes: 12 additions & 0 deletions
12
...-multimodule-test-java-version/test-module/src/main/java/com/example/tests/TestUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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"; | ||
| }; | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
java/ql/integration-tests/java/maven-multimodule-test-java-version/test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| def test(codeql, java, actions_toolchains_file): | ||
| codeql.database.create(_env={"LGTM_INDEX_MAVEN_TOOLCHAINS_FILE": str(actions_toolchains_file)}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Java analysis now selects the Java version to use informed by Maven POM files across all project modules. It also tries to use Java 17 or higher for all Maven projects if possible, for improved build compatibility. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after comma in 'e.g.,records'. Should be 'e.g., records' with a space after the comma.