Merge pull request #22347 from github/andersfugmann/fix-maven-enforce… · computersarebad/codeql@b196f0c · GitHub
Skip to content

Commit b196f0c

Browse files
Merge pull request github#22347 from github/andersfugmann/fix-maven-enforcer-property-version
Java: test Maven Enforcer project property expansion
2 parents 6d0f21d + 668f4e8 commit b196f0c

10 files changed

Lines changed: 228 additions & 0 deletions

File tree

Lines changed: 134 additions & 0 deletions
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<settings>
2+
<mirrors>
3+
<mirror>
4+
<id>google-maven-central</id>
5+
<name>GCS Maven Central mirror</name>
6+
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>
7+
<mirrorOf>central</mirrorOf>
8+
</mirror>
9+
</mirrors>
10+
</settings>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pom.xml
2+
settings.xml
3+
src/main/java/com/example/App.java
4+
src/main/resources/my-app.properties
5+
src/main/resources/page.xml
6+
src/main/resources/struts.xml
7+
src/test/java/com/example/AppTest.java
8+
target/classes/my-app.properties
9+
target/classes/page.xml
10+
target/classes/struts.xml
11+
target/maven-archiver/pom.properties
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.example;
2+
3+
import java.util.regex.Pattern;
4+
import java.nio.file.Path;
5+
import java.nio.file.Paths;
6+
7+
/**
8+
* Hello world!
9+
*
10+
*/
11+
public class App
12+
{
13+
public static void main( String[] args )
14+
{
15+
System.out.println( "Hello World!" );
16+
String expectedVersion = System.getenv("EXPECT_MAVEN");
17+
Path mavenHome = Paths.get(System.getProperty("maven.home")).normalize();
18+
String observedVersion = mavenHome.getFileName().toString();
19+
if (expectedVersion != null && !expectedVersion.equals(observedVersion)) {
20+
System.err.println("Wrong maven version, expected '" + expectedVersion + "' but got '" + observedVersion + "'" + mavenHome);
21+
System.exit(1);
22+
}
23+
String commandMatcher = System.getenv("EXPECT_COMMAND_REGEX");
24+
String command = System.getProperty("sun.java.command");
25+
if (commandMatcher != null && !Pattern.matches(commandMatcher, command)) {
26+
System.err.println("Wrong command line, '" + command + "' does not match '" + commandMatcher + "'");
27+
System.exit(1);
28+
}
29+
}
30+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=1.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>
3+
<title>A sample</title>
4+
</head>
5+
<body>
6+
<p>Hello world!</p>
7+
</body>
8+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<struts>
3+
This is a sample file
4+
</struts>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.example;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
import org.junit.Test;
6+
7+
/**
8+
* Unit test for simple App.
9+
*/
10+
public class AppTest
11+
{
12+
/**
13+
* Rigorous Test :-)
14+
*/
15+
@Test
16+
public void shouldAnswerWithTrue()
17+
{
18+
assertTrue( true );
19+
}
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import os
2+
3+
def test(codeql, java):
4+
codeql.database.create(
5+
_env={
6+
"EXPECT_MAVEN": "apache-maven-3.9.16",
7+
"LGTM_INDEX_MAVEN_SETTINGS_FILE": os.path.join(os.path.dirname(os.path.realpath(__file__)), "settings.xml"),
8+
},
9+
)

‎java/ql/integration-tests/java/maven-enforcer-single-version/test.py‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)