-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
scratch
] Try out the Gradle Tooling API
- Loading branch information
Showing
6 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
[versions] | ||
# SLF4J releases: http://www.slf4j.org/news.html | ||
slf4j = "2.0.7" | ||
slf4j = "2.0.7" # SLF4J releases: http://www.slf4j.org/news.html | ||
|
||
junit = "5.10.0" # JUnit releases: https://junit.org/junit5/docs/current/release-notes/index.html | ||
|
||
gradle = "8.2.1" # Gradle releases: https://gradle.org/releases | ||
|
||
[libraries] | ||
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } | ||
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" } | ||
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } | ||
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } | ||
gradle-tooling-api = { module = "org.gradle:gradle-tooling-api", version.ref = "gradle" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
package dgroomes; | ||
|
||
import org.gradle.tooling.GradleConnector; | ||
import org.gradle.tooling.ProjectConnection; | ||
import org.gradle.tooling.model.build.BuildEnvironment; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
|
||
public class Main { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(Main.class); | ||
|
||
public static void main(String[] args) { | ||
log.info(message()); | ||
} | ||
var externalProjectDir = new File("/Users/dave/repos/personal/arrow-playground/basic"); | ||
log.info("Let's inspect the Gradle 'build environment' for the project in the directory: {}", externalProjectDir); | ||
var gradleConnector = GradleConnector.newConnector().forProjectDirectory(externalProjectDir); | ||
|
||
public static String message() { | ||
return "Hello world!"; | ||
try (ProjectConnection connection = gradleConnector.connect()) { | ||
var buildEnvironment = connection.getModel(BuildEnvironment.class); | ||
log.info("The Gradle Tooling API found this 'build environment' information:"); | ||
log.info("Gradle version: {}", buildEnvironment.getGradle().getGradleVersion()); | ||
log.info("Gradle home: {}", buildEnvironment.getGradle().getGradleUserHome()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Configuring the 'slf4j-simple' logger | ||
org.slf4j.simpleLogger.showDateTime=TRUE | ||
org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss.SSS | ||
org.slf4j.simpleLogger.log.dgroomes=info | ||
org.slf4j.simpleLogger.log.org.gradle=info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters