Skip to content

Commit 69d8fa6

Browse files
authored
Merge pull request #16188 from smowton/smowton/admin/maven-buildless-missing-host-tolerance-test
Java: add test for a Maven project with an unreachable repository
2 parents 2627a3d + bdd6fba commit 69d8fa6

File tree

7 files changed

+297
-0
lines changed

7 files changed

+297
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
https://repo.maven.apache.org/maven2/com/blazegraph/junit-ext/2.1.4/junit-ext-2.1.4.jar
2+
https://repo.maven.apache.org/maven2/com/greghaskins/spectrum/1.2.0/spectrum-1.2.0-tests.jar
3+
https://repo.maven.apache.org/maven2/com/pyx4me/cldcunit/2.0.4/cldcunit-2.0.4.jar
4+
https://repo.maven.apache.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar
5+
https://repo1.maven.org/maven2/junit/junit/9.9.9/junit-9.9.9.jar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"markdownMessage": "At least one dependency JAR suggested by the build system could not be downloaded. This means the analysis will try to satisfy the dependency with its default choice for the required external package name, which may be the wrong version or the wrong package entirely. This may lead to partial analysis of code using this dependency. See the extraction log for full details. If the cause appears to be a temporary outage, consider retrying the analysis.",
3+
"severity": "warning",
4+
"source": {
5+
"extractorName": "java",
6+
"id": "java/extractor/buildless/suggested-classpath-fetches-failed",
7+
"name": "Some build-system suggested dependencies could not be fetched"
8+
},
9+
"visibility": {
10+
"cliSummaryTable": true,
11+
"statusPage": true,
12+
"telemetry": true
13+
}
14+
}
15+
{
16+
"markdownMessage": "Buildless extraction tried and failed to fetch a jar (`https://repo1.maven.org/maven2, junit:junit:jar:9.9.9`). If a temporary network outage is likely, consider retrying the scan.",
17+
"severity": "warning",
18+
"source": {
19+
"extractorName": "java",
20+
"id": "java/extractor/buildless/jar-fetch-failed",
21+
"name": "Fetching a dependency jar failed"
22+
},
23+
"visibility": {
24+
"cliSummaryTable": true,
25+
"statusPage": true,
26+
"telemetry": true
27+
}
28+
}
29+
{
30+
"markdownMessage": "Java analysis used build tool Maven to pick a JDK version and/or to recommend external dependencies.",
31+
"severity": "unknown",
32+
"source": {
33+
"extractorName": "java",
34+
"id": "java/autobuilder/buildless/using-build-tool-advice",
35+
"name": "Java analysis used build tool Maven to pick a JDK version and/or to recommend external dependencies"
36+
},
37+
"visibility": {
38+
"cliSummaryTable": true,
39+
"statusPage": false,
40+
"telemetry": true
41+
}
42+
}
43+
{
44+
"markdownMessage": "Java analysis used the system default JDK.",
45+
"severity": "unknown",
46+
"source": {
47+
"extractorName": "java",
48+
"id": "java/autobuilder/buildless/jdk-system-default",
49+
"name": "Java analysis used the system default JDK"
50+
},
51+
"visibility": {
52+
"cliSummaryTable": true,
53+
"statusPage": false,
54+
"telemetry": true
55+
}
56+
}
57+
{
58+
"markdownMessage": "Java analysis with build-mode 'none' completed.",
59+
"severity": "unknown",
60+
"source": {
61+
"extractorName": "java",
62+
"id": "java/autobuilder/buildless/complete",
63+
"name": "Java analysis with build-mode 'none' completed"
64+
},
65+
"visibility": {
66+
"cliSummaryTable": true,
67+
"statusPage": false,
68+
"telemetry": true
69+
}
70+
}
71+
{
72+
"markdownMessage": "Java was extracted with build-mode set to 'none'. This means that all Java source in the working directory will be scanned, with build tools such as Maven and Gradle only contributing information about external dependencies.",
73+
"severity": "note",
74+
"source": {
75+
"extractorName": "java",
76+
"id": "java/autobuilder/buildless/mode-active",
77+
"name": "Java was extracted with build-mode set to 'none'"
78+
},
79+
"visibility": {
80+
"cliSummaryTable": true,
81+
"statusPage": true,
82+
"telemetry": true
83+
}
84+
}
85+
{
86+
"markdownMessage": "Reading the dependency graph from build files provided 1 classpath entries",
87+
"severity": "unknown",
88+
"source": {
89+
"extractorName": "java",
90+
"id": "java/autobuilder/buildless/depgraph-provided-by-maven",
91+
"name": "Java analysis extracted precise dependency graph information from tool Maven"
92+
},
93+
"visibility": {
94+
"cliSummaryTable": true,
95+
"statusPage": false,
96+
"telemetry": true
97+
}
98+
}
99+
{
100+
"markdownMessage": "Running the Maven plugin `com.github.ferstl:depgraph-maven-plugin:4.0.2:graph` yielded an artifact transfer exception. This means some dependency information will be unavailable, and so some dependencies will be guessed based on Java package names. Consider investigating why this plugin encountered errors retrieving dependencies.",
101+
"severity": "warning",
102+
"source": {
103+
"extractorName": "java",
104+
"id": "java/autobuilder/buildless/depgraph-maven-plugin-transfer-exception",
105+
"name": "Java analysis encountered a transfer exception dependency graph from Maven"
106+
},
107+
"visibility": {
108+
"cliSummaryTable": true,
109+
"statusPage": true,
110+
"telemetry": true
111+
}
112+
}
113+
{
114+
"markdownMessage": "Some classpath entries had to be inferred from external package names used in source code -- for example, guessing that if `javax.xml.bind` is referred to, then JAXB should be added to the classpath. This means that the dependency information extracted from build scripts was insufficient. The dependencies guessed this way might be the wrong versions, leading to failure to extract some uses of those external libraries. The cause may be missing dependencies that should be generated at build time -- in this case, consider using a build mode other than 'none'. See the full analysis log for details of the inferred classpath entries.",
115+
"severity": "unknown",
116+
"source": {
117+
"extractorName": "java",
118+
"id": "java/extractor/buildless/supplied-classpath-insufficient",
119+
"name": "Some classpath entries were inferred from used external package names"
120+
},
121+
"visibility": {
122+
"cliSummaryTable": true,
123+
"statusPage": false,
124+
"telemetry": true
125+
}
126+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>dlfs</groupId>
8+
<artifactId>asdkfj</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<name>asdkfj</name>
12+
<description>A simple asdkfj.</description>
13+
<!-- FIXME change it to the project's website -->
14+
<url>http://www.example.com</url>
15+
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<maven.compiler.source>1.7</maven.compiler.source>
19+
<maven.compiler.target>1.7</maven.compiler.target>
20+
</properties>
21+
22+
<repositories>
23+
<repository>
24+
<id>my-repo1</id>
25+
<name>your custom repo</name>
26+
<url>https://saldkfjadksfj.info/releases</url>
27+
</repository>
28+
</repositories>
29+
30+
<dependencies>
31+
<dependency>
32+
<groupId>junit</groupId>
33+
<artifactId>junit</artifactId>
34+
<version>9.9.9</version>
35+
</dependency>
36+
</dependencies>
37+
38+
<build>
39+
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
40+
<plugins>
41+
<plugin>
42+
<artifactId>maven-clean-plugin</artifactId>
43+
<version>3.1.0</version>
44+
</plugin>
45+
<plugin>
46+
<artifactId>maven-site-plugin</artifactId>
47+
<version>3.7.1</version>
48+
</plugin>
49+
<plugin>
50+
<artifactId>maven-project-info-reports-plugin</artifactId>
51+
<version>3.0.0</version>
52+
</plugin>
53+
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
54+
<plugin>
55+
<artifactId>maven-resources-plugin</artifactId>
56+
<version>3.0.2</version>
57+
</plugin>
58+
<plugin>
59+
<artifactId>maven-compiler-plugin</artifactId>
60+
<version>3.8.0</version>
61+
</plugin>
62+
<plugin>
63+
<artifactId>maven-surefire-plugin</artifactId>
64+
<version>2.22.1</version>
65+
</plugin>
66+
<plugin>
67+
<artifactId>maven-jar-plugin</artifactId>
68+
<version>3.0.2</version>
69+
</plugin>
70+
<plugin>
71+
<artifactId>maven-install-plugin</artifactId>
72+
<version>2.5.2</version>
73+
</plugin>
74+
<plugin>
75+
<artifactId>maven-deploy-plugin</artifactId>
76+
<version>2.8.2</version>
77+
</plugin>
78+
</plugins>
79+
</pluginManagement>
80+
</build>
81+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package dlfs;
2+
3+
/**
4+
* Hello world!
5+
*
6+
*/
7+
public class App
8+
{
9+
public static void main( String[] args )
10+
{
11+
System.out.println( "Hello World!" );
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project name="asdkfj" xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd">
5+
<bannerLeft>
6+
<name>asdkfj</name>
7+
<src>https://maven.apache.org/images/apache-maven-project.png</src>
8+
<href>https://www.apache.org/</href>
9+
</bannerLeft>
10+
11+
<bannerRight>
12+
<src>https://maven.apache.org/images/maven-logo-black-on-white.png</src>
13+
<href>https://maven.apache.org/</href>
14+
</bannerRight>
15+
16+
<skin>
17+
<groupId>org.apache.maven.skins</groupId>
18+
<artifactId>maven-fluido-skin</artifactId>
19+
<version>1.7</version>
20+
</skin>
21+
22+
<body>
23+
<menu ref="parent" />
24+
<menu ref="reports" />
25+
</body>
26+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package dlfs;
2+
3+
import junit.framework.Test;
4+
import junit.framework.TestCase;
5+
import junit.framework.TestSuite;
6+
7+
/**
8+
* Unit test for simple App.
9+
*/
10+
public class AppTest
11+
extends TestCase
12+
{
13+
/**
14+
* Create the test case
15+
*
16+
* @param testName name of the test case
17+
*/
18+
public AppTest( String testName )
19+
{
20+
super( testName );
21+
}
22+
23+
/**
24+
* @return the suite of tests being tested
25+
*/
26+
public static Test suite()
27+
{
28+
return new TestSuite( AppTest.class );
29+
}
30+
31+
/**
32+
* Rigourous Test :-)
33+
*/
34+
public void testApp()
35+
{
36+
assertTrue( true );
37+
}
38+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from create_database_utils import *
2+
from diagnostics_test_utils import *
3+
from buildless_test_utils import *
4+
5+
run_codeql_database_create([], lang="java", extra_args=["--build-mode=none"])
6+
7+
check_diagnostics()
8+
check_buildless_fetches()

0 commit comments

Comments
 (0)