Skip to content

Java: add test exercising Gradle download pruning #19135

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 2 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* To learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.3/samples
*/

apply plugin: 'java-library'

repositories {
mavenCentral()
}

dependencies {
api 'org.apache.commons:commons-math3:3.6.1'

api 'org.junit.jupiter:junit-jupiter-api:5.12.1'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://repo.maven.apache.org/maven2/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar
https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar
https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter-api/5.12.1/junit-jupiter-api-5.12.1.jar
https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-commons/1.12.1/junit-platform-commons-1.12.1.jar
https://repo.maven.apache.org/maven2/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"markdownMessage": "Java analysis used build tool Gradle to pick a JDK version and/or to recommend external dependencies.",
"severity": "unknown",
"source": {
"extractorName": "java",
"id": "java/autobuilder/buildless/using-build-tool-advice",
"name": "Java analysis used build tool Gradle to pick a JDK version and/or to recommend external dependencies"
},
"visibility": {
"cliSummaryTable": true,
"statusPage": false,
"telemetry": true
}
}
{
"markdownMessage": "Java analysis used the system default JDK.",
"severity": "unknown",
"source": {
"extractorName": "java",
"id": "java/autobuilder/buildless/jdk-system-default",
"name": "Java analysis used the system default JDK"
},
"visibility": {
"cliSummaryTable": true,
"statusPage": false,
"telemetry": true
}
}
{
"markdownMessage": "Java analysis with build-mode 'none' completed.",
"severity": "unknown",
"source": {
"extractorName": "java",
"id": "java/autobuilder/buildless/complete",
"name": "Java analysis with build-mode 'none' completed"
},
"visibility": {
"cliSummaryTable": true,
"statusPage": false,
"telemetry": true
}
}
{
"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.",
"severity": "note",
"source": {
"extractorName": "java",
"id": "java/autobuilder/buildless/mode-active",
"name": "Java was extracted with build-mode set to 'none'"
},
"visibility": {
"cliSummaryTable": true,
"statusPage": true,
"telemetry": true
}
}
{
"markdownMessage": "Reading the dependency graph from build files provided 5 classpath entries",
"severity": "unknown",
"source": {
"extractorName": "java",
"id": "java/autobuilder/buildless/depgraph-provided-by-gradle",
"name": "Java analysis extracted precise dependency graph information from tool Gradle"
},
"visibility": {
"cliSummaryTable": true,
"statusPage": false,
"telemetry": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.3/userguide/building_swift_projects.html in the Gradle documentation.
*/

rootProject.name = 'buildless-gradle'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gradle/8.3/dependencies-accessors/gc.properties
.gradle/8.3/gc.properties
.gradle/buildOutputCleanup/cache.properties
.gradle/vcs-1/gc.properties
gradle/wrapper/gradle-wrapper.properties
src/main/java/com/fractestexample/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.fractestexample;

import org.apache.commons.math3.fraction.Fraction;

public class Test {

public Fraction test(org.junit.jupiter.api.Test t) { return Fraction.ONE; }

Comment on lines +7 to +8
Copy link
Preview

Copilot AI Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using org.junit.jupiter.api.Test as a parameter type appears to be incorrect; consider annotating the method with @test and removing the parameter to correctly define a test method.

Suggested change
public Fraction test(org.junit.jupiter.api.Test t) { return Fraction.ONE; }
@Test
public Fraction test() { return Fraction.ONE; }

Copilot uses AI. Check for mistakes.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def test(codeql, java, gradle_8_3):
codeql.database.create(
_env={
"CODEQL_EXTRACTOR_JAVA_OPTION_BUILDLESS": "true",
"CODEQL_EXTRACTOR_JAVA_OPTION_BUILDLESS_CLASSPATH_FROM_BUILD_FILES": "true",
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: fix
---
* In `build-mode: none` where the project has a Gradle build system, database creation no longer attempts to download some non-existent jar files relating to non-jar Maven artifacts, such as BOMs. This was harmless, but saves some time and reduces spurious warnings.