Skip to content

Commit e4a712c

Browse files
authored
Merge pull request #10402 from tamasvajk/kotlin-comp-args
Kotlin: Add integration test for compiler argument extraction
2 parents 40e77a0 + 16836de commit e4a712c

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* This file was generated by the Gradle 'init' task.
3+
*
4+
* This generated file contains a sample Kotlin application project to get you started.
5+
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
6+
* User Manual available at https://docs.gradle.org/7.0.2/userguide/building_java_projects.html
7+
*/
8+
9+
plugins {
10+
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
11+
id 'org.jetbrains.kotlin.jvm' version '1.7.0'
12+
13+
// Apply the application plugin to add support for building a CLI application in Java.
14+
id 'application'
15+
}
16+
17+
repositories {
18+
// Use Maven Central for resolving dependencies.
19+
mavenCentral()
20+
}
21+
22+
application {
23+
// Define the main class for the application.
24+
mainClass = 'testProject.AppKt'
25+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* This Kotlin source file was generated by the Gradle 'init' task.
3+
*/
4+
package testProject
5+
6+
class App {
7+
val greeting: String
8+
get() {
9+
return "Hello World!"
10+
}
11+
}
12+
13+
fun main() {
14+
// TODO: println(App().greeting)
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
| 0 | -Xallow-no-source-files |
2+
| 1 | -classpath |
3+
| 2 | <PATH> |
4+
| 3 | -d |
5+
| 4 | app/build/classes/kotlin/main |
6+
| 5 | -jdk-home |
7+
| 6 | <PATH> |
8+
| 7 | -module-name |
9+
| 8 | app |
10+
| 9 | -no-reflect |
11+
| 10 | -no-stdlib |
12+
| 11 | <PLUGINS> |
13+
| 12 | app/src/main/kotlin/testProject/App.kt |
14+
| 13 | -jvm-target |
15+
| 14 | 1.8 |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import java
2+
3+
private string getArgument(Compilation c, int i) {
4+
exists(string arg | arg = c.getArgument(i) |
5+
if exists(arg.indexOf("-Xplugin="))
6+
then result = "<PLUGINS>"
7+
else
8+
if c.getArgument(i - 1) = ["-classpath", "-jdk-home"]
9+
then result = "<PATH>"
10+
else result = arg
11+
)
12+
}
13+
14+
from Compilation c, int i
15+
select i, getArgument(c, i)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* This file was generated by the Gradle 'init' task.
3+
*
4+
* The settings file is used to specify which projects to include in your build.
5+
*
6+
* Detailed information about configuring a multi-project build in Gradle can be found
7+
* in the user manual at https://docs.gradle.org/7.0.2/userguide/multi_project_builds.html
8+
*/
9+
10+
rootProject.name = 'testProject'
11+
include('app')
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from create_database_utils import *
2+
3+
run_codeql_database_create(
4+
["gradle build --no-daemon --no-build-cache"], lang="java")
5+
runSuccessfully(["gradle", "clean"])

0 commit comments

Comments
 (0)