### Example JAVA_HOME Output (Windows) Source: https://docs.gradle.org/9.4.1/userguide/installation.html This example shows the JAVA_HOME variable set to a JDK 17 installation path on a Windows system. ```text C:\Program Files\Java\jdk17.0_6 ``` -------------------------------- ### Example Java Version Output Source: https://docs.gradle.org/9.4.1/userguide/installation.html This is an example output showing that OpenJDK version 17 is installed and recognized. ```text openjdk version "17.0.6" 2023-01-17 OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10) OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode) ``` -------------------------------- ### Build Output Example 2 Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Another example output after changing the build directory, demonstrating how paths are updated. ```bash > Task :generate configuration file = /home/user/gradle/samples/src/config.txt output dir = /home/user/gradle/samples/output/generated-source BUILD SUCCESSFUL in 0s 1 actionable task: 1 executed ``` -------------------------------- ### Example JAVA_HOME Output (macOS/Linux) Source: https://docs.gradle.org/9.4.1/userguide/installation.html This example shows the JAVA_HOME variable set to a JDK 17 installation path on a macOS system. ```text /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home ``` -------------------------------- ### Build Output Example 1 Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example output from running the 'generate' task, showing the configuration file path and the output directory. ```bash > Task :generate configuration file = /home/user/gradle/samples/kotlin/src/config.txt output dir = /home/user/gradle/samples/kotlin/output/generated-source BUILD SUCCESSFUL in 0s 1 actionable task: 1 executed ``` -------------------------------- ### Example Plugin Configuration (Groovy DSL) Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html An example demonstrating the configuration for the GradleTest plugin, including website, VCS URL, and detailed plugin properties. ```groovy gradlePlugin { website = 'https://github.com/ysb33r/gradleTest' vcsUrl = 'https://github.com/ysb33r/gradleTest.git' plugins { register('gradletestPlugin') { id = 'org.ysb33r.gradletest' displayName = 'Plugin for compatibility testing of Gradle plugins' description = 'A plugin that helps you test your plugin against a variety of Gradle versions' tags.addAll('testing', 'integrationTesting', 'compatibility') implementationClass = 'org.ysb33r.gradle.gradletest.GradleTestPlugin' } } } ``` -------------------------------- ### Example Plugin Configuration (Kotlin DSL) Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html An example demonstrating the configuration for the GradleTest plugin, including website, VCS URL, and detailed plugin properties. ```kotlin gradlePlugin { website = "https://github.com/ysb33r/gradleTest" vcsUrl = "https://github.com/ysb33r/gradleTest.git" plugins { register("gradletestPlugin") { id = "org.ysb33r.gradletest" displayName = "Plugin for compatibility testing of Gradle plugins" description = "A plugin that helps you test your plugin against a variety of Gradle versions" tags = listOf("testing", "integrationTesting", "compatibility") implementationClass = "org.ysb33r.gradle.gradletest.GradleTestPlugin" } } } ``` -------------------------------- ### Example JAVA_HOME Output Source: https://docs.gradle.org/9.4.1/userguide/troubleshooting.html This shows the expected output after setting the JAVA_HOME environment variable, confirming the path to your Java installation. ```text /Users/user/Library/Java/JavaVirtualMachines/corretto-22.0.1/Contents/Home ``` -------------------------------- ### Web Server Build Service Example Source: https://docs.gradle.org/9.4.1/userguide/build_services.html A comprehensive example of a build service that takes parameters (port, resources) and implements AutoCloseable for resource management. It starts a server and provides its URI. ```java import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.Property; import org.gradle.api.services.BuildService; import org.gradle.api.services.BuildServiceParameters; import java.net.URI; import java.net.URISyntaxException; public abstract class WebServer implements BuildService, AutoCloseable { // Some parameters for the web server interface Params extends BuildServiceParameters { Property getPort(); DirectoryProperty getResources(); } private final URI uri; public WebServer() throws URISyntaxException { // Use the parameters int port = getParameters().getPort().get(); uri = new URI(String.format("https://localhost:%d/", port)); // Start the server ... System.out.println(String.format("Server is running at %s", uri)); } // A public method for tasks to use public URI getUri() { return uri; } @Override public void close() { // Stop the server ... } } ``` -------------------------------- ### Get Install Directory API Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.language.nativeplatform/-component-with-installation/get-install-directory.html Provides access to the Gradle installation directory. ```APIDOC ## GET /installDirectory ### Description Returns the installation directory for Gradle. ### Method GET ### Endpoint /installDirectory ### Parameters None ### Request Example None ### Response #### Success Response (200) - **directory** (Directory) - The installation directory. #### Response Example { "directory": "/path/to/gradle/installation" } ``` -------------------------------- ### Example: Sign and publish a project Source: https://docs.gradle.org/9.4.1/userguide/publishing_signing.html Demonstrates the command to publish a project with signatures and the expected output, including the creation and execution of signing tasks. ```bash $ ./gradlew publish ``` ```text > Task :compileJava > Task :processResources > Task :classes > Task :jar > Task :javadoc > Task :javadocJar > Task :sourcesJar > Task :generateMetadataFileForMavenJavaPublication > Task :generatePomFileForMavenJavaPublication > Task :signMavenJavaPublication > Task :publishMavenJavaPublicationToMavenRepository > Task :publish BUILD SUCCESSFUL in 0s 10 actionable tasks: 10 executed ``` -------------------------------- ### Example: Signing a Configuration Output Source: https://docs.gradle.org/9.4.1/userguide/signing_plugin.html Demonstrates how to execute the Gradle task to sign runtime elements. ```bash $ ./gradlew signRuntimeElements ``` ```text > Task :compileJava > Task :processResources > Task :classes > Task :jar > Task :signRuntimeElements BUILD SUCCESSFUL in 0s 4 actionable tasks: 4 executed ``` -------------------------------- ### Get Operation Start Time Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.tooling.events/-operation-result/get-start-time.html Retrieves the time when the operation started its execution. ```APIDOC ## GET /api/operation/startTime ### Description Returns the time when the operation started its execution. ### Method GET ### Endpoint /api/operation/startTime ### Return #### Success Response (200) - **startTime** (Long) - The start time, in milliseconds since the epoch. ``` -------------------------------- ### Get Java Installation Metadata Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.jvm.toolchain/-java-compiler/get-metadata.html Retrieves metadata information about the Gradle 9.4.1 Java installation. ```APIDOC ## GET /api/java/metadata ### Description Returns metadata information about this tool. ### Method GET ### Endpoint /api/java/metadata ### Response #### Success Response (200) - **metadata** (JavaInstallationMetadata) - The tool metadata. #### Response Example ```json { "metadata": { "javaHome": "/path/to/java/home", "javaVersion": "17.0.1" } } ``` ``` -------------------------------- ### Initialization Phase Example (Kotlin) Source: https://docs.gradle.org/9.4.1/userguide/build_lifecycle_intermediate.html Demonstrates code executed during the initialization phase in a Kotlin settings file. ```kotlin rootProject.name = "basic" println("This is executed during the initialization phase.") ``` -------------------------------- ### Example Project Root Directory Structure Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Illustrates the typical structure of a Gradle project root directory, including cache, build, and configuration files. ```bash ├── .gradle // (1) │ ├── 4.8 // (2) │ ├── 4.9 // (2) │ └── ⋮ ├── build // (3) ├── gradle │ └── wrapper // (4) ├── gradle.properties // (5) ├── gradlew // (6) ├── gradlew.bat // (6) ├── settings.gradle.kts // (7) ├── subproject-one // (8) | └── build.gradle.kts // (9) ├── subproject-two // (8) | └── build.gradle.kts // (9) └── ⋮ ``` -------------------------------- ### Project Layout Example Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Illustrates a typical project layout for Gradle plugins, including buildSrc. ```text . ├── app/ │ └── build.gradle.kts ├── buildSrc/ │ ├── build.gradle.kts │ └── src/main/kotlin/MyPlugin.kt ├── settings.gradle.kts └── build.gradle.kts ``` ```text . ├── app/ │ └── build.gradle ├── buildSrc/ │ ├── build.gradle │ └── src/main/groovy/MyPlugin.groovy ├── settings.gradle └── build.gradle ``` -------------------------------- ### Initialization Phase Example (Groovy) Source: https://docs.gradle.org/9.4.1/userguide/build_lifecycle_intermediate.html Demonstrates code executed during the initialization phase in a Groovy settings file. ```groovy rootProject.name = 'basic' println 'This is executed during the initialization phase.' ``` -------------------------------- ### Start Parameter Project Properties Source: https://docs.gradle.org/9.4.1/javadoc/index-all.html Gets the key-value map of project properties from start parameters. ```APIDOC ## GET /api/startParameter/projectProperties ### Description Returns a key-value map of project properties. ### Method GET ### Endpoint /api/startParameter/projectProperties ### Parameters None ### Request Example None ### Response #### Success Response (200) - **properties** (map) - A map of project properties. #### Response Example { "properties": { "propertyName1": "propertyValue1", "propertyName2": "propertyValue2" } } ``` -------------------------------- ### Get Visual Studio Installation Directory Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.nativeplatform.toolchain/-visual-cpp/get-install-dir.html Retrieves the directory where Visual Studio or Visual C++ is installed. ```APIDOC ## GET /gradle/9.4.1/installDir ### Description Returns the directory where Visual Studio or Visual C++ is installed. ### Method GET ### Endpoint /gradle/9.4.1/installDir ### Response #### Success Response (200) - **installDir** (File) - The path to the Visual Studio or Visual C++ installation directory. #### Response Example ```json { "installDir": "/path/to/visualstudio" } ``` ``` -------------------------------- ### Sample Usage of Gradle Init Plugin Source: https://docs.gradle.org/9.4.1/userguide/build_init_plugin.html Demonstrates how to use the `gradle init` command with various parameters to create a new Java application project. Gradle will prompt for missing information interactively. ```bash gradle init \ --type java-application \ --dsl kotlin \ --test-framework junit-jupiter \ --package my.project \ --project-name my-project \ --no-split-project \ --java-version 17 ``` -------------------------------- ### Get Gradle Installation Path Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.jvm.toolchain/-java-installation-metadata/get-installation-path.html Retrieves the installation path for the current tool. This path is equivalent to the JAVA_HOME environment variable. ```kotlin abstract fun getInstallationPath(): Directory(source) ``` -------------------------------- ### StartParameter Prepare Methods Source: https://docs.gradle.org/9.4.1/javadoc/index-all.html Methods for preparing build or instance configurations. ```APIDOC ## StartParameter Prepare Methods ### Description Methods for preparing build or instance configurations. ### Methods #### `prepareNewBuild(StartParameter)` #### `prepareNewInstance(StartParameter)` ### Class #### `org.gradle.StartParameter` ``` -------------------------------- ### Multi-Project Structure Example (Kotlin) Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Illustrates a typical multi-project directory structure using Kotlin DSL. ```gradle-kotlin-dsl my-project/ ├── settings.gradle.kts // (1) ├── build.gradle.kts // (2) ├── app/ // (3) │ └── build.gradle.kts // (4) ├── core/ // (3) │ └── build.gradle.kts // (5) └── util/ // (3) └── build.gradle.kts // (6) ``` -------------------------------- ### Project Structure Example Source: https://docs.gradle.org/9.4.1/userguide/best_practices_structuring_builds.html Illustrates a recommended project structure with separate modules for application logic, core utilities, and utility implementations. ```text ├── app │ ├── build.gradle.kts │ └── src │ └── main │ └── java │ └── org │ └── example │ └── Main.java ├── settings.gradle.kts ├── util │ ├── build.gradle.kts │ └── src │ └── main │ └── java │ └── org │ └── example │ └── Util.java ├── util-commons │ ├── build.gradle.kts │ └── src │ └── main │ └── java │ └── org │ └── example │ └── CommonsUtil.java └── util-guava ├── build.gradle.kts └── src └── main └── java └── org └── example └── GuavaUtil.java ``` ```text ├── app // App contains only the core application logic │ ├── build.gradle │ └── src │ └── main │ └── java │ └── org │ └── example │ └── Main.java ├── settings.gradle ├── util // Util contains only the core utility logic │ ├── build.gradle │ └── src │ └── main │ └── java │ └── org │ └── example │ └── Util.java ├── util-commons // One particular implementation of util, using Apache Commons │ ├── build.gradle │ └── src │ └── main │ └── java │ └── org │ └── example │ └── CommonsUtil.java └── util-guava // Another implementation of util, using Guava ├── build.gradle └── src └── main └── java └── org └── example └── GuavaUtil.java ``` -------------------------------- ### Project Structure Example Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Illustrates a typical multi-project Gradle build structure for a Java application. ```text gradle-project ├── app │ ├── build.gradle.kts │ └── src // some java code │ └── ... ├── utilities │ ├── build.gradle.kts │ └── src // some java code │ └── ... ├── list │ ├── build.gradle.kts │ └── src // some java code │ └── ... ├── buildSrc │ ├── build.gradle.kts │ ├── settings.gradle.kts │ └── src // common build logic │ └── ... ├── settings.gradle.kts ├── gradle ├── gradlew └── gradlew.bat ``` ```text gradle-project ├── app │ ├── build.gradle │ └── src // some java code │ └── ... ├── utilities │ ├── build.gradle │ └── src // some java code │ └── ... ├── list │ ├── build.gradle │ └── src // some java code │ └── ... ├── buildSrc │ ├── build.gradle │ ├── settings.gradle │ └── src // common build logic │ └── ... ├── settings.gradle ├── gradle ├── gradlew └── gradlew.bat ``` -------------------------------- ### GET /installationPath Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.jvm.toolchain/-java-installation-metadata/get-installation-path.html Retrieves the installation path for the Gradle tool. ```APIDOC ## GET /installationPath ### Description Retrieves the installation path for the Gradle tool. This path is equivalent to the JAVA_HOME environment variable for the given installation. ### Method GET ### Endpoint /installationPath ### Return - **Directory** - The path to the installation directory. ``` -------------------------------- ### GET /installation Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.nativeplatform/-native-executable-binary-spec/get-installation.html Retrieves the native installation specification for a native executable. ```APIDOC ## GET /installation ### Description Retrieves the native installation specification for a native executable. ### Method GET ### Endpoint /installation ### Response #### Success Response (200) - **source** (NativeInstallationSpec) - The native installation specification. ``` -------------------------------- ### GET /getInstallTask Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.language.nativeplatform/-component-with-installation/get-install-task.html Retrieves the install task for the current project configuration. ```APIDOC ## GET /getInstallTask ### Description Returns the install task. ### Method GET ### Endpoint /getInstallTask ### Response #### Success Response (200) - **task** (Provider) - The install task provider. ``` -------------------------------- ### Execute a Gradle Build with BuildLauncher Source: https://docs.gradle.org/9.4.1/javadoc/org/gradle/tooling/BuildLauncher.html This example demonstrates how to create and configure a BuildLauncher to execute Gradle tasks. It shows setting tasks, arguments, standard input, Java home, JVM arguments, and adding a progress listener. ```java ProjectConnection connection = GradleConnector.newConnector() .forProjectDirectory(new File("some-folder")) .connect(); try { BuildLauncher build = connection.newBuild(); //select tasks to run: build.forTasks("clean", "test"); //include some build arguments: build.withArguments("-i", "--project-dir", "some-project-dir"); //configure the standard input: build.setStandardInput(new ByteArrayInputStream("consume this!".getBytes())); //in case you want the build to use java different than default: build.setJavaHome(new File("/path/to/java")); //if your build needs crazy amounts of memory: build.setJvmArguments("-Xmx2048m", "-XX:MaxPermSize=512m"); //if you want to listen to the progress events: ProgressListener listener = null; // use your implementation build.addProgressListener(listener); //kick the build off: build.run(); } finally { connection.close(); } ``` -------------------------------- ### Get Distribution Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.api.publish.maven/-maven-pom-license/get-distribution.html Retrieves the distribution information for the current Gradle setup. ```APIDOC ## GET /gradle/distribution ### Description Retrieves the distribution of this license. ### Method GET ### Endpoint /gradle/distribution ### Response #### Success Response (200) - **distribution** (Property) - The distribution of this license. #### Response Example { "distribution": "Gradle 9.4.1" } ``` -------------------------------- ### Example Gradle Command and Output Source: https://docs.gradle.org/9.4.1/userguide/incremental_build.html Demonstrates how to execute a task and the expected output when the task is skipped due to having no source files. ```bash $ ./gradlew clean processTemplatesAdHocSkipWhenEmpty ``` ```text > Task :processTemplatesAdHocSkipWhenEmpty NO-SOURCE BUILD SUCCESSFUL in 0s 3 actionable tasks: 2 executed, 1 up-to-date ``` -------------------------------- ### Multi-Project Structure Example (Groovy) Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Illustrates a typical multi-project directory structure using Groovy DSL. ```gradle-groovy my-project/ ├── settings.gradle // (1) ├── build.gradle // (2) ├── app/ // (3) │ └── build.gradle // (4) ├── core/ // (3) │ └── build.gradle // (5) └── util/ // (3) └── build.gradle // (6) ``` -------------------------------- ### Get Java Version Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.tooling.model.java/-installed-jdk/get-java-version.html Retrieves the version of the Java installation used by Gradle. ```APIDOC ## GET /api/java/version ### Description Retrieves the version of the Java installation. ### Method GET ### Endpoint /api/java/version ### Return #### Success Response (200) - **version** (JavaVersion) - The Java version. Never returns `null`. ``` -------------------------------- ### Gradle Configuration Example Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.language.rc/-windows-resource-set/index.html Example of how to configure the windows-resources plugin and define a Windows Resource set in a Gradle build script. ```APIDOC ## Gradle Configuration Example ### Description This example demonstrates how to apply the 'windows-resources' plugin and configure a `rc` source set within a `NativeLibrarySpec` component. ### Code ```groovy plugins { id 'windows-resources' } model { components { main(NativeLibrarySpec) { sources { rc { source { srcDirs "src/main/rc" include "**/*.rc" } exportedHeaders { srcDirs "src/main/include" } } } } } } ``` ``` -------------------------------- ### Groovy DSL Project Layout Example Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example of a project layout using Groovy DSL with separate Java and Kotlin source directories. ```gradle . ├── build.gradle └── src └── main ├── java │ └── HelloWorld.java └── kotlin └── Utils.kt ``` -------------------------------- ### Kotlin Task with All Input/Output Annotations Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html This Kotlin example demonstrates a Gradle task class declaring all available input and output annotations. Ensure you have the necessary Gradle setup for custom task classes. ```kotlin abstract class AllTypes : DefaultTask() { //inputs @get:Input abstract val inputString: Property @get:InputFile abstract val inputFile: RegularFileProperty @get:InputDirectory abstract val inputDirectory: DirectoryProperty @get:InputFiles abstract val inputFileCollection: ConfigurableFileCollection @get:Classpath abstract val inputClasspath: ConfigurableFileCollection // outputs @get:OutputFile abstract val outputFile: RegularFileProperty @get:OutputDirectory abstract val outputDirectory: DirectoryProperty @get:OutputFiles abstract val outputFiles: ConfigurableFileCollection @get:OutputDirectories abstract val outputDirectories: ConfigurableFileCollection } ``` -------------------------------- ### Groovy Property Usage Examples Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Provides practical examples of setting the project version, task descriptions, and file paths using Groovy syntax. It also shows how to print embedded property values. ```groovy version = '1.0.1' myCopyTask.description = 'Copies some files' file("$projectDir/src") println "Destination: ${myCopyTask.destinationDir}" ``` -------------------------------- ### Example Build with File System Watching and Verbose Logging Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html This command demonstrates running a Gradle build with both file system watching enabled and verbose VFS logging activated. It shows the typical output related to file system events and VFS state. ```bash $ ./gradlew assemble --watch-fs -Dorg.gradle.vfs.verbose=true ``` ```text $ ./gradlew assemble --watch-fs -Dorg.gradle.vfs.verbose=true Received 3 file system events since last build while watching 1 locations Virtual file system retained information about 2 files, 2 directories and 0 missing files since last build > Task :compileJava NO-SOURCE > Task :processResources NO-SOURCE > Task :classes UP-TO-DATE > Task :jar UP-TO-DATE > Task :assemble UP-TO-DATE BUILD SUCCESSFUL in 58ms 1 actionable task: 1 up-to-date Received 5 file system events during the current build while watching 1 locations Virtual file system retains information about 3 files, 2 directories and 2 missing files until next build ``` -------------------------------- ### Get Java Home Directory Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.tooling.model.java/-installed-jdk/get-java-home.html Retrieves the home directory of the Java installation. ```APIDOC ## GET /java/home ### Description Retrieves the home directory of the Java installation. ### Method GET ### Endpoint /java/home ### Return #### Success Response (200) - **javaHome** (File) - The home directory of the Java installation. Never returns null. ``` -------------------------------- ### Dependency Tree Output Example Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example output of the Gradle `dependencies` task, showing implementation and runtime dependencies, including transitive ones. ```text > Task :app:dependencies ------------------------------------------------------------ Project ':app' ------------------------------------------------------------ implementation - Implementation dependencies for the 'main' feature. (n) \--- com.google.guava:guava:30.0-jre (n) runtimeClasspath - Runtime classpath of source set 'main'. +--- com.google.guava:guava:30.0-jre | +--- com.google.guava:failureaccess:1.0.1 | +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava | +--- com.google.code.findbugs:jsr305:3.0.2 | +--- org.checkerframework:checker-qual:3.5.0 | +--- com.google.errorprone:error_prone_annotations:2.3.4 | \--- com.google.j2objc:j2objc-annotations:1.3 \--- org.apache.commons:commons-lang3:3.14.0 runtimeOnly - Runtime-only dependencies for the 'main' feature. (n) \--- org.apache.commons:commons-lang3:3.14.0 (n) ``` -------------------------------- ### Kotlin DSL Project Layout Example Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example of a project layout using Kotlin DSL with separate Java and Kotlin source directories. ```gradle . ├── build.gradle.kts └── src └── main ├── java │ └── HelloWorld.java └── kotlin └── Utils.kt ``` -------------------------------- ### Gradle Properties File Configuration Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example of a gradle.properties file showing Gradle, system, and project properties. ```properties # Gradle properties org.gradle.parallel=true org.gradle.caching=true org.gradle.jvmargs=-Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 # System properties systemProp.pts.enabled=true systemProp.log4j2.disableJmx=true systemProp.file.encoding = UTF-8 # Project properties kotlin.code.style=official android.nonTransitiveRClass=false spring-boot.version = 2.2.1.RELEASE ``` -------------------------------- ### Get Windows SDK Directory Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.nativeplatform.toolchain/-visual-cpp/get-windows-sdk-dir.html Retrieves the installation directory of the Windows SDK. ```APIDOC ## GET /websites/gradle_9_4_1/getWindowsSdkDir ### Description Returns the directory where the Windows SDK is installed. ### Method GET ### Endpoint /websites/gradle_9_4_1/getWindowsSdkDir ### Response #### Success Response (200) - **File** (File) - The path to the Windows SDK installation directory. ``` -------------------------------- ### Create and Navigate to Project Directory Source: https://docs.gradle.org/9.4.1/userguide/part1_gradle_init.html Create a new directory for your project and navigate into it. This is where your Gradle project will be initialized. ```bash $ mkdir tutorial ``` ```bash $ cd tutorial ``` -------------------------------- ### Example Build Output Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Illustrates the output when a task is executed and another task it depends on is excluded. ```text > Task :compile compiling source > Task :dist building the distribution BUILD SUCCESSFUL in 0s 2 actionable tasks: 2 executed ``` -------------------------------- ### GET /getRunScriptFile Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.nativeplatform.tasks/-install-executable/get-run-script-file.html Retrieves the script file that can be used to run the install image. ```APIDOC ## GET /getRunScriptFile ### Description Returns the script file that can be used to run the install image. ### Method GET ### Endpoint /getRunScriptFile ### Response #### Success Response (200) - **scriptFile** (Provider) - The script file provider. #### Response Example { "scriptFile": "path/to/run.sh" } ``` -------------------------------- ### Project Layout Example (Kotlin) Source: https://docs.gradle.org/9.4.1/userguide/best_practices_general.html Illustrates a typical project structure including build scripts and a custom plugin in Kotlin. ```kotlin . ├── app/ │ └── build.gradle.kts ├── buildSrc/ │ ├── build.gradle.kts │ └── src/main/kotlin/MyPlugin.kt ├── settings.gradle.kts └── build.gradle.kts ``` -------------------------------- ### GET /websites/gradle_9_4_1/getLibs Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.nativeplatform.tasks/-install-executable/get-libs.html Retrieves the library files that should be installed for the specified Gradle project. ```APIDOC ## GET /websites/gradle_9_4_1/getLibs ### Description Retrieves the library files that should be installed. ### Method GET ### Endpoint /websites/gradle_9_4_1/getLibs ### Parameters ### Request Body ### Request Example ### Response #### Success Response (200) - **source** (FileCollection) - The library files to be installed. #### Response Example ```json { "source": "[FileCollection Object]" } ``` ``` -------------------------------- ### Start Gradle Daemon in Foreground Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Starts the Gradle Daemon process in the foreground. ```bash --foreground ``` -------------------------------- ### Project Structure Example (Groovy) Source: https://docs.gradle.org/9.4.1/userguide/organizing_gradle_projects.html Illustrates the file system structure of a multi-project build with 'app' and 'lib' subprojects using Groovy DSL. ```text . __**(1)** ├── settings.gradle __**(2)** ├── app/ __**(3)** │ ├── build.gradle __**(4)** │ └── src/ └── lib/ __**(3)** ├── build.gradle __**(4)** └── src/ ``` -------------------------------- ### Get File - EclipseClasspath Source: https://docs.gradle.org/9.4.1/javadoc/org/gradle/plugins/ide/eclipse/model/EclipseClasspath.html Retrieves the XmlFileContentMerger. See file(Action) for an example. ```java public XmlFileContentMerger getFile() ``` -------------------------------- ### Default App Tasks Output Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example output showing the extensive list of default tasks available in the 'app' subproject. ```text > Task :app:tasks ------------------------------------------------------------ Tasks runnable from project ':app' ------------------------------------------------------------ Application tasks ----------------- run - Runs this project as a JVM application Build tasks ----------- assemble - Assembles the outputs of this project. build - Assembles and tests this project. buildDependents - Assembles and tests this project and all projects that depend on it. buildNeeded - Assembles and tests this project and all projects it depends on. classes - Assembles main classes. clean - Deletes the build directory. jar - Assembles a jar archive containing the classes of the 'main' feature. testClasses - Assembles test classes. Distribution tasks ------------------ assembleDist - Assembles the main distributions distTar - Bundles the project as a distribution. distZip - Bundles the project as a distribution. installDist - Installs the project as a distribution as-is. Documentation tasks ------------------- javadoc - Generates Javadoc API documentation for the 'main' feature. Help tasks ---------- buildEnvironment - Displays all buildscript dependencies declared in project ':app'. dependencies - Displays all dependencies declared in project ':app'. dependencyInsight - Displays the insight into a specific dependency in project ':app'. help - Displays a help message. javaToolchains - Displays the detected java toolchains. kotlinDslAccessorsReport - Prints the Kotlin code for accessing the currently available project extensions and conventions. outgoingVariants - Displays the outgoing variants of project ':app'. projects - Displays the sub-projects of project ':app'. properties - Displays the properties of project ':app'. resolvableConfigurations - Displays the configurations that can be resolved in project ':app'. tasks - Displays the tasks runnable from project ':app'. Verification tasks ------------------ check - Runs all checks. test - Runs the test suite. ``` -------------------------------- ### Gradle Build Output Example Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example output from a Gradle build, showing task execution and cache status. This output indicates the tasks that were executed and their outcomes. ```text :compileJava :processResources :classes :jar :assemble BUILD SUCCESSFUL ``` -------------------------------- ### Example Dependency Graph Output Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html This is a truncated example of the output from the 'app:dependencies' task, illustrating the hierarchical structure of dependencies and their versions for the 'runtimeClasspath' configuration. ```text runtimeClasspath - Runtime classpath of source set 'main'. \--- com.fasterxml.jackson.core:jackson-databind:2.17.2 +--- com.fasterxml.jackson.core:jackson-annotations:2.17.2 | \--- com.fasterxml.jackson:jackson-bom:2.17.2 | +--- com.fasterxml.jackson.core:jackson-annotations:2.17.2 | +--- com.fasterxml.jackson.core:jackson-core:2.17.2 | \--- com.fasterxml.jackson.core:jackson-databind:2.17.2 +--- com.fasterxml.jackson.core:jackson-core:2.17.2 | \--- com.fasterxml.jackson:jackson-bom:2.17.2 \--- com.fasterxml.jackson:jackson-bom:2.17.2 ``` -------------------------------- ### StartParameter Configuration Source: https://docs.gradle.org/9.4.1/javadoc/org/gradle/api/tasks/GradleBuild.html Methods for getting and setting the start parameters for a Gradle build. ```APIDOC ## Method Details ### getStartParameter `@Internal public StartParameter getStartParameter()` Returns the full set of parameters that will be used to execute the build. Returns: the parameters. Never returns null. ### setStartParameter `public void setStartParameter(StartParameter startParameter)` Sets the full set of parameters that will be used to execute the build. Parameters: `startParameter` - the parameters. Should not be null. ``` -------------------------------- ### Create and Configure a Configuration Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.api.artifacts/-configuration-container/index.html Demonstrates how to create a new configuration and set its properties. Use this to define custom dependency sets. ```gradle configurations.create('myConfiguration') configurations.myConfiguration.transitive = false ``` -------------------------------- ### BuildLauncher Usage Example Source: https://docs.gradle.org/9.4.1/javadoc/org/gradle/tooling/BuildLauncher.html This example demonstrates how to create, configure, and run a Gradle build using the BuildLauncher interface. ```APIDOC ## BuildLauncher Usage Example ### Description This example demonstrates how to create, configure, and run a Gradle build using the BuildLauncher interface. It covers setting tasks, arguments, standard input, Java home, JVM arguments, and progress listeners. ### Method `run()` ### Endpoint N/A (This is a programmatic API usage example) ### Parameters None directly for the `run()` method, but configuration is done via `BuildLauncher` methods. ### Request Example ```java ProjectConnection connection = GradleConnector.newConnector() .forProjectDirectory(new File("some-folder")) .connect(); try { BuildLauncher build = connection.newBuild(); //select tasks to run: build.forTasks("clean", "test"); //include some build arguments: build.withArguments("-i", "--project-dir", "some-project-dir"); //configure the standard input: build.setStandardInput(new ByteArrayInputStream("consume this!".getBytes())); //in case you want the build to use java different than default: build.setJavaHome(new File("/path/to/java")); //if your build needs crazy amounts of memory: build.setJvmArguments("-Xmx2048m", "-XX:MaxPermSize=512m"); //if you want to listen to the progress events: ProgressListener listener = null; // use your implementation build.addProgressListener(listener); //kick the build off: build.run(); } finally { connection.close(); } ``` ### Response #### Success Response (void) This method does not return a value upon successful execution. The build output and results are typically captured by Gradle's standard output or logging mechanisms. #### Response Example N/A (void return type) ``` -------------------------------- ### Groovy: Bad Task Dependency Example Source: https://docs.gradle.org/9.4.1/userguide/best_practices_tasks.html This Groovy example demonstrates an incorrect task dependency setup using `dependsOn`. Gradle lacks the context to optimize task execution. ```groovy abstract class SimpleTranslationTask extends DefaultTask { @InputFile abstract RegularFileProperty getMessageFile() @OutputFile abstract RegularFileProperty getTranslatedFile() SimpleTranslationTask() { messageFile.convention(project.layout.buildDirectory.file("message.txt")) translatedFile.convention(project.layout.buildDirectory.file("translated.txt")) } @TaskAction __**(1)** void run() { def message = messageFile.get().asFile.text def translatedMessage = message == "Hello" ? "Bonjour" : "Unknown" logger.lifecycle("Translation: " + translatedMessage) translatedFile.get().asFile.write(translatedMessage) } } tasks.register("translateBad", SimpleTranslationTask) { dependsOn(tasks.named("helloWorld")) __**(2)** } ``` -------------------------------- ### Dependency Insight Output Example Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example output from the `dependencyInsight` task, showing dependency details, variant attributes, and selection reasons. ```text org.ow2.asm:asm:7.1 Variant compile: | Attribute Name | Provided | Requested | |--------------------------------|----------|--------------| | org.gradle.status | release | | | org.gradle.category | library | library | | org.gradle.libraryelements | jar | classes | | org.gradle.usage | java-api | java-api | | org.gradle.dependency.bundling | | external | | org.gradle.jvm.environment | | standard-jvm | | org.gradle.jvm.version | | 11 | Selection reasons: - Was requested: we require a JDK 9 compatible bytecode generator org.ow2.asm:asm:7.1 \--- compileClasspath A web-based, searchable dependency report is available by adding the --scan option. ``` -------------------------------- ### Get Java Version Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.tooling.model.java/-java-runtime/get-java-version.html Retrieves the Java version of the current Java runtime installation. ```APIDOC ## GET /java/version ### Description Retrieves the Java version of the Java runtime installation. ### Method GET ### Endpoint /java/version ### Response #### Success Response (200) - **version** (JavaVersion) - The Java version. Never returns `null`. #### Response Example ```json { "version": "11.0.11" } ``` ``` -------------------------------- ### Project Structure Example (Kotlin) Source: https://docs.gradle.org/9.4.1/userguide/organizing_gradle_projects.html Illustrates the file system structure of a multi-project build with 'app' and 'lib' subprojects using Kotlin DSL. ```text . __**(1)** ├── settings.gradle.kts __**(2)** ├── app/ __**(3)** │ ├── build.gradle.kts __**(4)** │ └── src/ └── lib/ __**(3)** ├── build.gradle.kts __**(4)** └── src/ ``` -------------------------------- ### Project Structure Output Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example output from the 'projects' task, showing the root project and its subprojects. ```text Projects: ------------------------------------------------------------ Root project 'my-project' ------------------------------------------------------------ Location: /home/user/gradle/samples Project hierarchy: Root project 'my-project' \--- Project ':app' Project locations: project ':app' - /app ``` -------------------------------- ### Get Java Home Directory Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.tooling.model.java/-java-runtime/get-java-home.html Retrieves the home directory of the Java runtime installation. ```APIDOC ## GET /api/java/home ### Description Retrieves the home directory of the Java runtime installation. This API endpoint is part of the Gradle project, specifically version 9.4.1. ### Method GET ### Endpoint /websites/gradle_9_4_1/api/java/home ### Response #### Success Response (200) - **javaHome** (File) - The home directory of the Java runtime installation. This value is guaranteed to be non-null. ``` -------------------------------- ### Build Output for Test and TestBoth Tasks Source: https://docs.gradle.org/9.4.1/userguide/build_lifecycle.html Example output showing the order of execution across initialization, configuration, and execution phases for the specified tasks. ```text This is executed during the initialization phase. > Configure project : This is executed during the configuration phase. This is executed during the configuration phase as well, because :testBoth is used in the build. > Task :test This is executed during the execution phase. > Task :testBoth This is executed first during the execution phase. This is executed last during the execution phase. BUILD SUCCESSFUL in 0s 2 actionable tasks: 2 executed ``` -------------------------------- ### Android Application Build Script (Kotlin) Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Example of a build.gradle.kts file for an Android application, demonstrating plugin application and dependency declarations. ```kotlin plugins { id("com.android.application") version "8.13.0" id("org.jetbrains.kotlin.android") version "2.1.20" id("org.jetbrains.kotlin.kapt") version "2.1.20" } dependencies { implementation("androidx.core:core-ktx:1.13.1") kapt("androidx.room:room-compiler:2.6.1") implementation("androidx.room:room-ktx:2.6.1") debugImplementation("com.squareup.leakcanary:leakcanary-android:2.14") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.2.1") androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") } ``` -------------------------------- ### Settings File Example (Kotlin) Source: https://docs.gradle.org/9.4.1/userguide/more_about_tasks.html Example settings file content for a project using Kotlin. ```kotlin rootProject.name = "gradle-project" include("app") ``` -------------------------------- ### JavaLauncher Interface Source: https://docs.gradle.org/9.4.1/kotlin-dsl/gradle/org.gradle.jvm.toolchain/-java-launcher/index.html Provides methods to get the executable path and metadata of a Java installation. ```APIDOC ## JavaLauncher Interface ### Description A java executable used to execute applications or run tests. ### Members #### Functions ##### getExecutablePath - **Description**: Returns the path to the executable for this tool. - **Returns**: `RegularFile` - The path to the executable. ##### getMetadata - **Description**: Returns metadata information about this tool. - **Returns**: `JavaInstallationMetadata` - Metadata about the Java installation. ``` -------------------------------- ### Execute Task with Dependencies Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html This command-line example shows how to execute `taskX` using Gradle. The output demonstrates that `taskY` is executed before `taskX` due to the defined dependency. ```bash $ ./gradlew -q taskX ``` -------------------------------- ### Execute Build with Gradle Wrapper (Windows) Source: https://docs.gradle.org/9.4.1/userguide/gradle_wrapper.html Demonstrates how to run a build using the Gradle Wrapper on a Windows machine. The Wrapper handles downloading and setting up the correct Gradle distribution if it's not already present. ```bash $ gradlew.bat build ``` -------------------------------- ### Get Containers - EclipseClasspath Source: https://docs.gradle.org/9.4.1/javadoc/org/gradle/plugins/ide/eclipse/model/EclipseClasspath.html Retrieves the classpath containers to be added. See EclipseClasspath for an example. ```java public Set getContainers() ``` -------------------------------- ### Method Calls with Arguments Source: https://docs.gradle.org/9.4.1/userguide/userguide_single.html Shows an example of calling a method with multiple arguments, specifically for task configuration like including files. ```Groovy myCopyTask.include '**/*.xml', '**/*.properties' ```