Skip to content

Commit 839e4b2

Browse files
authored
Merge pull request #19047 from smowton/smowton/admin/add-gradle-download-failure-test
Java: add integration test for failed Gradle download
2 parents f53de13 + 834594f commit 839e4b2

File tree

9 files changed

+205
-0
lines changed

9 files changed

+205
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# These are explicitly windows files and should use crlf
5+
*.bat text eol=crlf
6+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* This build file was auto generated by running the Gradle 'init' task
3+
* by 'arthur' at '28/11/20 22:29' with Gradle 3.0
4+
*
5+
* This generated file contains a sample Java project to get you started.
6+
* For more details take a look at the Java Quickstart chapter in the Gradle
7+
* user guide available at https://docs.gradle.org/3.0/userguide/tutorial_java_projects.html
8+
*/
9+
10+
// Apply the java plugin to add support for Java
11+
apply plugin: 'java'
12+
13+
// In this section you declare where to find the dependencies of your project
14+
repositories {
15+
// Use 'jcenter' for resolving your dependencies.
16+
// You can declare any Maven/Ivy/file repository here.
17+
jcenter()
18+
}
19+
20+
// In this section you declare the dependencies for your production and test code
21+
dependencies {
22+
// The production code uses the SLF4J logging API at compile time
23+
compile 'org.slf4j:slf4j-api:1.7.21'
24+
25+
// Declare the dependency for your favourite test framework you want to use in your tests.
26+
// TestNG is also supported by the Gradle Test task. Just change the
27+
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
28+
// 'test.useTestNG()' to your build script.
29+
testCompile 'junit:junit:4.12'
30+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"markdownMessage": "Build tool(s) should have been able to provide a recommended classpath but the attempt failed. Extraction will continue, but external dependencies will be inferred from the Java package names used. Consider troubleshooting the build tool error or using a build mode other than 'none'.",
3+
"severity": "note",
4+
"source": {
5+
"extractorName": "java",
6+
"id": "java/autobuilder/buildless/classpath-from-tool-failed",
7+
"name": "Failed to extract dependency information from build tool tool Gradle"
8+
},
9+
"visibility": {
10+
"cliSummaryTable": true,
11+
"statusPage": true,
12+
"telemetry": true
13+
}
14+
}
15+
{
16+
"markdownMessage": "Built a Gradle project without the [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html). This may use an incompatible version of Gradle.",
17+
"severity": "warning",
18+
"source": {
19+
"extractorName": "java",
20+
"id": "java/autobuilder/guessed-gradle-version",
21+
"name": "Required Gradle version not specified"
22+
},
23+
"visibility": {
24+
"cliSummaryTable": true,
25+
"statusPage": true,
26+
"telemetry": true
27+
}
28+
}
29+
{
30+
"markdownMessage": "Java analysis used build tool Gradle 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 Gradle 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": "Running the Gradle plugin `org.gradle:github-dependency-graph-gradle-plugin` failed. This means precise dependency information will be unavailable, and so dependencies will be guessed based on Java package names. Consider investigating why this plugin fails to run.",
87+
"severity": "note",
88+
"source": {
89+
"extractorName": "java",
90+
"id": "java/autobuilder/buildless/github-dependency-graph-gradle-plugin-failed",
91+
"name": "Java analysis failed to extract a dependency graph from Gradle"
92+
},
93+
"visibility": {
94+
"cliSummaryTable": true,
95+
"statusPage": true,
96+
"telemetry": true
97+
}
98+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This settings file was auto generated by the Gradle buildInit task
3+
* by 'arthur' at '28/11/20 22:29' with Gradle 3.0
4+
*
5+
* The settings file is used to specify which projects to include in your build.
6+
* In a single project build this file can be empty or even removed.
7+
*
8+
* Detailed information about configuring a multi-project build in Gradle can be found
9+
* in the user guide at https://docs.gradle.org/3.0/userguide/multi_project_builds.html
10+
*/
11+
12+
/*
13+
// To declare projects as part of a multi-project build use the 'include' method
14+
include 'shared'
15+
include 'api'
16+
include 'services:webservice'
17+
*/
18+
19+
rootProject.name = 'gradle-sample'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/main/java/com/example/App.java
2+
src/test/java/com/example/AppTest.java
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* This Java source file was generated by the Gradle 'init' task.
3+
*/
4+
package com.example;
5+
6+
public class App {
7+
public String getGreeting() {
8+
return "Hello world.";
9+
}
10+
11+
public static void main(String[] args) {
12+
System.out.println(new App().getGreeting());
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* This Java source file was generated by the Gradle 'init' task.
3+
*/
4+
package com.example;
5+
6+
import org.junit.Test;
7+
import static org.junit.Assert.*;
8+
9+
public class AppTest {
10+
@Test public void testAppHasAGreeting() {
11+
App classUnderTest = new App();
12+
assertNotNull("app should have a greeting", classUnderTest.getGreeting());
13+
}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import tempfile
2+
import runs_on
3+
import pathlib
4+
5+
6+
# The version of gradle used doesn't work on java 17
7+
def test(codeql, use_java_11, java, environment):
8+
gradle_override_dir = pathlib.Path(tempfile.mkdtemp())
9+
if runs_on.windows:
10+
(gradle_override_dir / "gradle.bat").write_text("@echo off\nexit /b 2\n")
11+
else:
12+
gradlepath = gradle_override_dir / "gradle"
13+
gradlepath.write_text("#!/bin/bash\nexit 1\n")
14+
gradlepath.chmod(0o0755)
15+
16+
environment.add_path(gradle_override_dir)
17+
codeql.database.create(build_mode = "none")

0 commit comments

Comments
 (0)