### Build Output Example Source: https://docs.gradle.org/current/userguide/implementing_custom_tasks.html Example output from Gradle after successfully executing the 'packageApp' task, showing the tasks that were run. ```text > Task :app:compileJava > Task :app:processResources NO-SOURCE > Task :app:classes > Task :app:jar > Task :app:packageApp BUILD SUCCESSFUL in 1s 3 actionable tasks: 3 executed ``` -------------------------------- ### Example configuration for GradleTest plugin Source: https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html A complete example showing how to configure metadata and plugin details for the GradleTest plugin. ```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" } } } ``` ```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 String Option Output Source: https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/CoreJavadocOptions.html Example of how addStringOption produces command-line arguments. ```text -foo 'bar baz' ``` -------------------------------- ### Implement a Closeable Build Service with Parameters Source: https://docs.gradle.org/current/userguide/build_services.html Example of a WebServer build service that takes parameters (port, resources) and implements AutoCloseable for cleanup. The service starts and prints its URI upon creation. ```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 ... } } ``` -------------------------------- ### File Pattern Examples Source: https://docs.gradle.org/current/javadoc/org/gradle/normalization/RuntimeClasspathNormalization.html Examples of file patterns used for matching resources in classpath entries. ```text all files ending with '.json' (including files in subdirectories) **/*.json ``` ```text all files beginning with 'build-' in the level1/level2 directory level1/level2/build-* ``` ```text all files (including subdirectories) beneath config/build-data config/build-data/ ``` ```text all properties files in a build directory beneath com/acme (including subdirectories) com/acme/**/build/*.properties ``` -------------------------------- ### Project Structure Example (Kotlin) Source: https://docs.gradle.org/current/userguide/best_practices_general.html Example project layout for a Gradle project using Kotlin build scripts. ```plaintext . ├── app/ │ └── build.gradle.kts ├── buildSrc/ │ ├── build.gradle.kts │ └── src/main/kotlin/MyPlugin.kt ├── settings.gradle.kts └── build.gradle.kts ``` -------------------------------- ### Get Operation Start Time Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.tooling.events/-operation-result/get-start-time.html Retrieves the time when the operation started its execution. ```APIDOC ## GET /websites/gradle_current/startTime ### Description Returns the time when the operation started its execution. ### Method GET ### Endpoint /websites/gradle_current/startTime ### Return #### Success Response (200) - **startTime** (Long) - The start time, in milliseconds since the epoch. ``` -------------------------------- ### Initialize project directory Source: https://docs.gradle.org/current/userguide/part1_gradle_init_project.html Create a new directory for the project and navigate into it. ```bash $ mkdir authoring-tutorial ``` ```bash $ cd authoring-tutorial ``` -------------------------------- ### Get Build Started Time Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api.invocation/-build-invocation-details/get-build-started-time.html Retrieves the wall-clock time in milliseconds when the Gradle build was started. ```APIDOC ## GET /build/started-time ### Description Returns the wall-clock time in milliseconds that the build was started. The build is considered to have started as soon as the user, or some tool, initiated the build. During continuous build, subsequent builds are timed from when changes are noticed. ### Method GET ### Endpoint /build/started-time ### Response #### Success Response (200) - **buildStartedTime** (Long) - The wall-clock time in milliseconds that the build was started. ``` -------------------------------- ### Execute the demo task Source: https://docs.gradle.org/current/userguide/gradle_managed_types.html Command to trigger the task registration example. ```bash $ ./gradlew demoTask ``` -------------------------------- ### Use Gradle Installation Source: https://docs.gradle.org/current/javadoc/org/gradle/tooling/GradleConnector.html Specify a local Gradle installation to be used for the connection by providing its home directory. ```java .useInstallation(new File("somePath")) ``` -------------------------------- ### Project Structure Example (Groovy) Source: https://docs.gradle.org/current/userguide/best_practices_general.html Example project layout for a Gradle project using Groovy build scripts. ```plaintext . ├── app/ │ └── build.gradle ├── buildSrc/ │ ├── build.gradle │ └── src/main/groovy/MyPlugin.groovy ├── settings.gradle └── build.gradle ``` -------------------------------- ### GET /websites/gradle_current/getLibs Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.nativeplatform.tasks/-install-executable/get-libs.html Retrieves the library files that should be installed. ```APIDOC ## GET /websites/gradle_current/getLibs ### Description Retrieves the library files that should be installed. ### Method GET ### Endpoint /websites/gradle_current/getLibs ### Parameters ### Request Body ### Request Example ### Response #### Success Response (200) - **source** (FileCollection) - The library files to be installed. #### Response Example { "example": "FileCollection" } ``` -------------------------------- ### Task Help Output Source: https://docs.gradle.org/current/userguide/custom_tasks.html Example output showing documented options and their available values. ```text Detailed task information for processUrl Path :processUrl Type UrlProcess (UrlProcess) Options --http Configures the http protocol to be allowed. --no-http Disables option --http. --output-type Configures the output type. Available values are: CONSOLE FILE --url Configures the URL to send the request to. --rerun Causes the task to be re-run even if up-to-date. Description - Group - ``` -------------------------------- ### Create and Navigate to Project Folder Source: https://docs.gradle.org/current/samples/sample_building_groovy_applications_multi_project.html Use the `mkdir` and `cd` commands to create a new project directory and enter it. This is the initial step before initializing a Gradle project. ```bash $ mkdir demo $ cd demo ``` -------------------------------- ### GET /getInstallTask Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.language.nativeplatform/-component-with-installation/get-install-task.html Retrieves the install task provider. ```APIDOC ## GET /getInstallTask ### Description Returns the install task provider. ### Method GET ### Endpoint /getInstallTask ### Response #### Success Response (200) - **Provider** (Provider) - The install task provider. ``` -------------------------------- ### View init task help Source: https://docs.gradle.org/current/userguide/build_init_plugin.html Displays available command-line options for the init task. ```bash gradle help --task init ``` -------------------------------- ### Get Java Version Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.tooling.model.java/-installed-jdk/get-java-version.html Retrieves the version of the Java installation. ```APIDOC ## GET /javaVersion ### Description Retrieves the version of the Java installation. ### Method GET ### Endpoint /javaVersion ### Return The Java version. Never returns `null`. ``` -------------------------------- ### GET /getLength Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api.problems/-offset-in-file-location/get-length.html Retrieves the length of the content starting from the offset. ```APIDOC ## getLength ### Description The length of the content starting from getOffset. ### Return - **length** (Int) - The length of the content. ### Since 8.13 ``` -------------------------------- ### Example Gradle Command and Output Source: https://docs.gradle.org/current/userguide/writing_build_scripts_intermediate.html Demonstrates a Gradle command to check properties and the expected output. ```bash $ gradle -q check ``` ```text project-api project-api ``` -------------------------------- ### GET testInstallDirectory Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.nativeplatform.test.xctest.tasks/-x-c-test/test-install-directory.html Retrieves the test install directory property configured for the project. ```APIDOC ## GET testInstallDirectory ### Description Retrieves the DirectoryProperty representing the test install directory. It is configured with PathSensitivity.RELATIVE. ### Method GET ### Parameters #### Path Sensitivity - **PathSensitivity** (RELATIVE) - The path is treated as relative to the project root. ### Response #### Success Response (200) - **testInstallDirectory** (DirectoryProperty) - The directory property object containing the source path. ``` -------------------------------- ### Example of Classpath and Sourcepath Usage Source: https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/CoreJavadocOptions.html Demonstrates how to specify both classpath and sourcepath for documenting a package that relies on external libraries. ```bash javadoc -classpath /user/lib -sourcepath /user/src com.mypackage ``` -------------------------------- ### Examples of Property Assignment and Access Source: https://docs.gradle.org/current/userguide/groovy_build_script_primer.html Demonstrates setting a project version, assigning a description to a task, and accessing a task's destination directory. ```groovy version = '1.0.1' myCopyTask.description = 'Copies some files' file("$projectDir/src") println "Destination: ${myCopyTask.destinationDir}" ``` -------------------------------- ### GET /getInstall Source: https://docs.gradle.org/current/javadoc/org/gradle/nativeplatform/NativeExecutableBinarySpec.TasksCollection.html Retrieves the install task associated with the native executable binary. ```APIDOC ## GET getInstall ### Description Retrieves the install task for the native executable binary. ### Method GET ### Endpoint getInstall() ### Response #### Success Response (200) - **Task** (Object) - The install task instance. ``` -------------------------------- ### Execute a Gradle Build with BuildLauncher Source: https://docs.gradle.org/current/javadoc/org/gradle/tooling/BuildLauncher.html Demonstrates how to create, configure, and run a Gradle build using the BuildLauncher. This includes setting tasks, arguments, standard input, Java home, JVM arguments, and adding a progress listener. Ensure the connection is closed in a finally block. ```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(); } ``` -------------------------------- ### StartParameter Configuration Source: https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/GradleBuild.html Methods for getting and setting the start parameters for a Gradle build. ```APIDOC ## GET /startParameter ### Description Retrieves the full set of parameters that will be used to execute the build. ### Method GET ### Endpoint `/startParameter` ### Parameters None ### Response #### Success Response (200) - **startParameter** (StartParameter) - The parameters for the build. Never null. ``` ```APIDOC ## SET /startParameter ### Description Sets the full set of parameters that will be used to execute the build. ### Method SET ### Endpoint `/startParameter` ### Parameters #### Request Body - **startParameter** (StartParameter) - Required - The parameters to set for the build. Should not be null. ``` -------------------------------- ### GET /getInstall Source: https://docs.gradle.org/current/javadoc/org/gradle/nativeplatform/test/NativeTestSuiteBinarySpec.TasksCollection.html Retrieves the install task associated with the native test suite binary. ```APIDOC ## GET /getInstall ### Description Returns the install task used for building the binary. ### Method GET ### Endpoint /getInstall ### Response #### Success Response (200) - **Task** (Object) - The install task instance. ``` -------------------------------- ### Get DidWork Status Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api.tasks/-work-result/index.html Retrieves a boolean indicating if work was performed. No setup is required. ```kotlin abstract fun getDidWork(): Boolean ``` -------------------------------- ### Execute Gradle Build with Wrapper (Windows) Source: https://docs.gradle.org/current/userguide/gradle_wrapper.html Demonstrates how to execute a Gradle build using the Wrapper on a Windows machine. The Wrapper will download the specified Gradle distribution if it's not already cached. ```bash $ gradlew.bat build ``` -------------------------------- ### Get Operation Start Time Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.tooling.events/-operation-result/index.html Retrieves the timestamp when an operation began. This is useful for calculating the total execution time. ```kotlin abstract fun getStartTime(): Long ``` -------------------------------- ### Install Gradle using SDKMAN! Source: https://docs.gradle.org/current/userguide/installation.html Use the SDKMAN! tool to install Gradle. SDKMAN! manages parallel versions of multiple Software Development Kits on Unix-like systems. ```bash $ sdk install gradle ``` -------------------------------- ### ModelBuilder - get (async) Source: https://docs.gradle.org/current/javadoc/org/gradle/tooling/ModelBuilder.html Starts fetching the model asynchronously, passing the result to a handler upon completion or failure. ```APIDOC ## POST /gradle/tooling/modelbuilder/get_async ### Description Starts fetching the model, passing the result to the given handler when complete. This method returns immediately, and the result is later passed to the given handler's `ResultHandler.onComplete(Object)` method. If the operation fails, the handler's `ResultHandler.onFailure(GradleConnectionException)` method is called with the appropriate exception. See `get()` for a description of the various exceptions that the operation may fail with. ### Method POST ### Endpoint /gradle/tooling/modelbuilder/get_async ### Parameters #### Request Body - **handler** (ResultHandler) - Required - The handler to supply the result to. ### Response #### Success Response (200) - **status** (string) - Indicates the operation has been initiated. #### Error Response - **IllegalStateException** - When the connection has been closed or is closing. ### Response Example { "status": "initiated" } ``` -------------------------------- ### Get Native Installation Spec Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.nativeplatform/-native-executable-binary-spec/get-installation.html Retrieves the NativeInstallationSpec for a native executable. Use this to define the source location for native binaries. ```kotlin abstract fun getInstallation(): NativeInstallationSpec(source) ``` -------------------------------- ### Gradle Wrapper Download and Setup Output Source: https://docs.gradle.org/current/userguide/gradle_wrapper_basics.html This console output shows the Gradle Wrapper downloading and setting up a specific Gradle version (e.g., 5.0) for the project on a Windows machine. ```text $ gradlew.bat build Downloading https://services.gradle.org/distributions/gradle-5.0-all.zip ..................................................................................... Unzipping C:\Documents and Settings\Claudia\.gradle\wrapper\dists\gradle-5.0-all\ac27o8rbd0ic8ih41or9l32mv\gradle-5.0-all.zip to C:\Documents and Settings\Claudia\.gradle\wrapper\dists\gradle-5.0-al\ac27o8rbd0ic8ih41or9l32mv Set executable permissions for: C:\Documents and Settings\Claudia\.gradle\wrapper\dists\gradle-5.0-all\ac27o8rbd0ic8ih41or9l32mv\gradle-5.0\bin\gradle BUILD SUCCESSFUL in 12s 1 actionable task: 1 executed ``` -------------------------------- ### Get Tool Metadata in Kotlin Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.jvm.toolchain/-javadoc-tool/get-metadata.html Call this function to retrieve metadata information about a tool. Ensure the tool is properly installed and configured. ```kotlin abstract fun getMetadata(): JavaInstallationMetadata(source) ``` -------------------------------- ### org.gradle.buildinit Package Overview Source: https://docs.gradle.org/current/javadoc/org/gradle/buildinit/package-summary.html Overview of the build initialization package structure and related components. ```APIDOC ## Package org.gradle.buildinit ### Description This package contains the plugins and tasks that power the 'gradle init' command. It provides the necessary infrastructure to bootstrap new Gradle projects. ### Related Packages - **org.gradle**: The top-level package for the Gradle build system. - **org.gradle.buildinit.plugins**: Contains build init plugins. - **org.gradle.buildinit.specs**: Provides the API for plugins to contribute additional types of builds to the init task. - **org.gradle.buildinit.tasks**: Contains build init tasks. ### Enums - **InsecureProtocolOption**: Defines options for handling insecure protocols when generating a project with repositories. ``` -------------------------------- ### Get Build Started Time Source: https://docs.gradle.org/current/javadoc/org/gradle/api/invocation/BuildInvocationDetails.html Retrieve the wall-clock time in milliseconds when the build was initiated. For continuous builds, this time is relative to when changes are detected. ```java long getBuildStartedTime() ``` -------------------------------- ### Categorized task list example Source: https://docs.gradle.org/current/userguide/task_basics.html View a sample output of the 'tasks' command, showing how tasks are grouped by category (e.g., Application, Build, Documentation). This helps in navigating and understanding the available build actions. ```text 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. ... Documentation tasks ------------------- javadoc - Generates Javadoc API documentation for the main source code. ... Other tasks ----------- compileJava - Compiles main Java source. ... ``` -------------------------------- ### Get Configuration Variant Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api.component/-configuration-variant-details/get-configuration-variant.html Use this function to retrieve the current configuration variant. No specific setup is required beyond having a Gradle project context. ```kotlin abstract fun getConfigurationVariant(): ConfigurationVariant ``` -------------------------------- ### Project hierarchy output Source: https://docs.gradle.org/current/userguide/migrating_from_maven.html Example output showing the project structure after configuration. ```text Projects: ------------------------------------------------------------ Root project 'simple-multi-module' ------------------------------------------------------------ Location: /home/user/gradle/samples Project hierarchy: Root project 'simple-multi-module' +--- Project ':simple-weather' \--- Project ':simple-webapp' Project locations: project ':simple-weather' - /simple-weather project ':simple-webapp' - /simple-webapp To see a list of the tasks of a project, run gradle :tasks For example, try running gradle :simple-weather:tasks ``` -------------------------------- ### InstallExecutable Properties and Methods Source: https://docs.gradle.org/current/javadoc/org/gradle/nativeplatform/tasks/InstallExecutable.html Details on the properties and methods available for the InstallExecutable task, such as getting the tool chain, target platform, installation directory, and executable file. ```APIDOC ## Method Details ### getToolChain @Internal public Property getToolChain() The tool chain used for linking. Since: 4.7 ### getTargetPlatform public Property getTargetPlatform() The platform being linked for. Since: 4.7 ### getInstallDirectory @OutputDirectory public DirectoryProperty getInstallDirectory() The directory to install files into. Since: 4.1 ### getExecutableFile @Internal("Covered by inputFileIfExists") public RegularFileProperty getExecutableFile() The executable file to install. Since: 4.7 ### getInstalledExecutable @OutputFile public RegularFileProperty getInstalledExecutable() The location of the installed executable file. Since: 4.7 ### getInputFileIfExists @SkipWhenEmpty @Optional @PathSensitive(NAME_ONLY) @InputFile protected @Nullable File getInputFileIfExists() Workaround for when the task is given an input file that doesn't exist Since: 4.3 ### getLibs @PathSensitive(RELATIVE) @InputFiles public FileCollection getLibs() The library files that should be installed. ### setLibs public void setLibs(FileCollection libs) ### lib public void lib(Object libs) Adds a set of library files to be installed. The provided libs object is evaluated as per `Project.files(Object...) ### getRunScriptFile @Internal("covered by getInstallDirectory") public Provider getRunScriptFile() Returns the script file that can be used to run the install image. Since: 4.4 ### getFileSystem @Inject protected abstract org.gradle.internal.nativeintegration.filesystem.FileSystem getFileSystem() ### getFileSystemOperations @Inject protected abstract FileSystemOperations getFileSystemOperations() ### install protected void install() ``` -------------------------------- ### Implement a Hello World Binary Plugin Source: https://docs.gradle.org/current/userguide/binary_plugin_advanced.html A complete example of a custom plugin that registers a task to print a message. ```kotlin abstract class SamplePlugin : Plugin { __**(1)** override fun apply(project: Project) { __**(2)** project.tasks.register("ScriptPlugin") { doLast { println("Hello world from the build file!") } } } } apply() __**(3)** ``` ```groovy class SamplePlugin implements Plugin { __**(1)** void apply(Project project) { __**(2)** project.tasks.register("ScriptPlugin") { doLast { println("Hello world from the build file!") } } } } apply plugin: SamplePlugin __**(3)** ``` -------------------------------- ### Get Synchronization Tasks Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.plugins.ide.eclipse.model/-eclipse-model/get-synchronization-tasks.html Retrieves the tasks to be executed before the Eclipse synchronization starts. These tasks are utilized by Buildship to run configured tasks before project import or synchronization. ```APIDOC ## GET /websites/gradle_current/synchronizationTasks ### Description Returns the tasks to be executed before the Eclipse synchronization starts. This property doesn't have a direct effect on the Gradle Eclipse plugin's behavior. It is used, however, by Buildship to execute the configured tasks each time before the user imports the project or before a project synchronization starts. ### Method GET ### Endpoint /websites/gradle_current/synchronizationTasks ### Return - **tasks** (TaskDependency) - The tasks names ### Since 5.4 ``` -------------------------------- ### Run Gradle Init Task Source: https://docs.gradle.org/current/samples/sample_building_swift_libraries.html Execute the `gradle init` task to set up a new Gradle project. Select 'library' as the project type and 'Swift' as the implementation language. Choose your preferred DSL (Kotlin or Groovy) for build scripts. ```bash $ gradle init Select type of build to generate: 1: Application 2: Library 3: Gradle plugin 4: Basic (build structure only) Enter selection (default: Application) [1..4] 2 Select implementation language: 1: Java 2: Kotlin 3: Groovy 4: Scala 5: C++ 6: Swift Enter selection (default: Java) [1..6] 6 Project name (default: demo): Select build script DSL: 1: Kotlin 2: Groovy Enter selection (default: Kotlin) [1..2] Generate build using new APIs and behavior (some features may change in the next minor release)? (default: no) [yes, no] BUILD SUCCESSFUL 1 actionable task: 1 executed ``` -------------------------------- ### Declare a 'boolean' property with 'is' getter Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.model/-managed/index.html For boolean properties (not Boolean objects), a getter starting with 'is' is also supported in addition to the standard 'get' prefix. ```java void setEnabled(boolean enabled); boolean isEnabled(); ``` -------------------------------- ### Configuring Gradle Options Source: https://docs.gradle.org/current/userguide/console.html Examples of setting options with values and using boolean flags. ```bash gradle [...] --console=plain ``` ```bash gradle [...] --build-cache gradle [...] --no-build-cache ``` ```bash gradle --help gradle -h ``` -------------------------------- ### Execute Init Script with Kotlin DSL Source: https://docs.gradle.org/current/userguide/init_scripts.html Command-line example to execute a Gradle build using an init script written in Kotlin DSL. The `-q` flag silences output, and `doNothing` is the task to run. ```bash $ ./gradlew --init-script init.gradle.kts -q doNothing ``` -------------------------------- ### GET /websites/gradle_current/getType Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.buildinit.specs/-build-init-spec/get-type.html Retrieves the unique identifier for the project type generated by this spec. This ID is used with the `--type` parameter in the `init` task for non-interactive project setup. ```APIDOC ## GET /websites/gradle_current/getType ### Description An identifier for the type of project this spec will generate. This will be used to allow the user to select a project type when running the `init` task non-interactively by supplying the `--type` parameter to the init task. Each project type can be registered to only a single BuildInitGenerator. ### Method GET ### Endpoint /websites/gradle_current/getType ### Return - **String** - type id for this type of project ### Since 8.12 ``` -------------------------------- ### Get Help (Full Option) Source: https://docs.gradle.org/current/userguide/command_line_interface_basics.html Display help information using the full option name. Use `./gradlew` for the Gradle Wrapper. ```bash gradle --help ``` -------------------------------- ### Conditionally Configure Test Task for CI (Groovy) Source: https://docs.gradle.org/current/userguide/common_caching_problems.html Configure a 'doFirst' action for Test tasks only when running in a CI environment. This example demonstrates a setup that would break caching. ```groovy if (System.getenv().containsKey("CI")) { tasks.withType(Test).configureEach { doFirst { println "Running test on CI" } } } ``` -------------------------------- ### Conditionally Configure Test Task for CI (Kotlin) Source: https://docs.gradle.org/current/userguide/common_caching_problems.html Configure a 'doFirst' action for Test tasks only when running in a CI environment. This example demonstrates a setup that would break caching. ```kotlin if ("CI" in System.getenv()) { tasks.withType().configureEach { doFirst { println("Running test on CI") } } } ``` -------------------------------- ### Apply Gradle Plugins Source: https://docs.gradle.org/current/userguide/part4_gradle_plugins.html Examples of applying core, community, and custom convention plugins. ```gradle plugins { id("java") } ``` ```gradle plugins { id("com.diffplug.spotless") version "6.25.0" } ``` ```gradle plugins { id("myproject.java-conventions") } ``` -------------------------------- ### Gradle Task Execution Example Source: https://docs.gradle.org/current/userguide/lazy_configuration.html Demonstrates how to execute the 'generate' Gradle task from the command line and shows the expected output, including the resolved file paths. ```bash $ gradle generate ``` ```text > 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 ``` ```bash $ gradle generate ``` ```text > 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 ``` -------------------------------- ### GET /gradle/tasks Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.testkit.runner/-build-result/get-tasks.html Retrieves the list of tasks that were part of the build. The order of tasks corresponds to their start time. For parallel builds, the order is not guaranteed to be deterministic. Returns an empty list if no tasks were executed. ```APIDOC ## GET /gradle/tasks ### Description Retrieves the list of tasks that were part of the build. The order of tasks corresponds to their start time. For parallel builds, the order is not guaranteed to be deterministic. Returns an empty list if no tasks were executed. ### Method GET ### Endpoint /gradle/tasks ### Return - **List** - The build tasks. The returned list is an unmodifiable view and will be empty if no tasks were executed. ``` -------------------------------- ### Get Help (Short Option) Source: https://docs.gradle.org/current/userguide/command_line_interface_basics.html Display help information using the short option equivalent. Use `./gradlew` for the Gradle Wrapper. ```bash gradle -h ``` -------------------------------- ### Get LibrarySpec in Gradle Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.platform.base/-library-binary-spec/get-library.html Use this function to retrieve the LibrarySpec object representing the library to which the current binary belongs. No specific setup or imports are required beyond the standard Gradle build script context. ```kotlin abstract fun getLibrary(): LibrarySpec(source) ``` -------------------------------- ### Project Bootstrapping Source: https://docs.gradle.org/current/userguide/console.html Commands for initializing new projects and provisioning the Gradle wrapper. ```APIDOC ## Bootstrapping ### Description Commands to initialize new builds or standardize the Gradle version using the wrapper. ### Commands - **gradle init** - Initializes a new build. Supports --type (e.g., basic, java-library). - **gradle wrapper** - Generates the gradlew script. Supports --gradle-version, --distribution-type, --gradle-distribution-url, and --gradle-distribution-sha256-sum. ``` -------------------------------- ### Run the application with arguments Source: https://docs.gradle.org/current/samples/sample_java_modules_with_transform.html Example command to execute the application with specific JSON input and debug flags. ```bash run --args='-json {"message":"Hello","receivers":["Lisa","John"]} -debug' ``` -------------------------------- ### Avoid Provider.get() in Task Configuration (Groovy) Source: https://docs.gradle.org/current/userguide/best_practices_tasks.html This Groovy example illustrates the problematic use of `myInput.get()` within the task action. Using `get()` prematurely evaluates the provider, potentially causing configuration cache issues. ```groovy abstract class MyTask extends DefaultTask { @Input abstract Property getMyInput() @OutputFile abstract RegularFileProperty getMyOutput() @TaskAction void doAction() { def outputFile = myOutput.get().asFile def outputText = myInput.get() __**(1)** println(outputText) outputFile.write(outputText) } } Provider currentEnvironment = providers.gradleProperty("currentEnvironment").orElse("234") __**(2)** ``` -------------------------------- ### Adding and Using Extensions Source: https://docs.gradle.org/current/dsl/org.gradle.api.plugins.ExtensionAware.html Demonstrates how to define a custom extension, add it to a project, and access its properties. Also shows how extensions can be nested and how to use the 'ext' property for extra properties. ```Groovy // Extensions are just plain objects, there is no interface/type class MyExtension { String foo MyExtension(String foo) { this.foo = foo } } // Add new extensions via the extension container project.extensions.create('custom', MyExtension, "bar") // («name», «type», «constructor args», …) // extensions appear as properties on the target object by the given name assert project.custom instanceof MyExtension assert project.custom.foo == "bar" // also via a namespace method project.custom { assert foo == "bar" foo = "other" } assert project.custom.foo == "other" // Extensions added with the extension container's create method are themselves extensible assert project.custom instanceof ExtensionAware project.custom.extensions.create("nested", MyExtension, "baz") assert project.custom.nested.foo == "baz" // All extension aware objects have a special "ext" extension of type ExtraPropertiesExtension assert project.hasProperty("myProperty") == false project.ext.myProperty = "myValue" // Properties added to the "ext" extension are promoted to the owning object assert project.myProperty == "myValue" ``` -------------------------------- ### Get Module Type Mappings Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.plugins.ear.descriptor/-deployment-descriptor/get-module-type-mappings.html Retrieves the mapping of module paths to module types. This map is non-null by default. For example, to specify that a module is a java module, set `moduleTypeMappings["myJavaModule.jar"] = "java"`. ```kotlin abstract fun getModuleTypeMappings(): Map ``` -------------------------------- ### Retrieve Custom Additional Data (Java) Source: https://docs.gradle.org/current/samples/sample_problems_api_usage.html Access custom additional data from a problem report using the defined view type. This example demonstrates casting the additional data to `CustomAdditionalData` and then using the view type to get specific fields. ```java AdditionalData data = problem.getAdditionalData(); if (data instanceof CustomAdditionalData) { System.out.println(" - additional data: " + ((CustomAdditionalData) data).get(SomeDataView.class).getName()); } ``` -------------------------------- ### Declare Repository Filter in Groovy Source: https://docs.gradle.org/current/userguide/filtering_repository_content.html Use the `content` block within a repository declaration to specify inclusion or exclusion rules. This example shows how to include artifacts from 'my.company' in a custom Maven repository and exclude artifacts starting with 'my.company' from mavenCentral. ```groovy repositories { maven { url = "https://repo.mycompany.com/maven2" content { // this repository *only* contains artifacts with group "my.company" includeGroup "my.company" } } mavenCentral { content { // this repository contains everything BUT artifacts with group starting with "my.company" excludeGroupByRegex "my\\.company.*" } } } ``` -------------------------------- ### Declare Repository Filter in Kotlin Source: https://docs.gradle.org/current/userguide/filtering_repository_content.html Use the `content` block within a repository declaration to specify inclusion or exclusion rules. This example shows how to include artifacts from 'my.company' in a custom Maven repository and exclude artifacts starting with 'my.company' from mavenCentral. ```kotlin repositories { maven { url = uri("https://repo.mycompany.com/maven2") content { // this repository *only* contains artifacts with group "my.company" includeGroup("my.company") } } mavenCentral { content { // this repository contains everything BUT artifacts with group starting with "my.company" excludeGroupByRegex("my\\.company.* ") } } } ``` -------------------------------- ### Project Structure Example (Groovy) Source: https://docs.gradle.org/current/userguide/implementing_custom_tasks.html Illustrates the typical project structure for a Gradle project with Groovy DSL. ```gradle gradle-project ├── app │ ├── build.gradle // app build logic │ ├── run.sh // script file │ └── ... // some java code ├── settings.gradle // includes app subproject ├── gradle ├── gradlew └── gradlew.bat ``` -------------------------------- ### Configure Java Toolchain for Java 7 in Kotlin DSL Source: https://docs.gradle.org/current/userguide/building_java_projects.html Use Java toolchains to specify the desired Java language version for compilation. This example configures the toolchain to use Java 7. Ensure Java 7 is installed and detectable by Gradle. ```kotlin java { toolchain { languageVersion = JavaLanguageVersion.of(7) } } ``` -------------------------------- ### Execute Init Script with Groovy DSL Source: https://docs.gradle.org/current/userguide/init_scripts.html Command-line example to execute a Gradle build using an init script written in Groovy DSL. The `-q` flag silences output, and `doNothing` is the task to run. ```bash $ ./gradlew --init-script init.gradle -q doNothing ``` -------------------------------- ### Apply Specific Plugin in hello-a/build.gradle.kts Source: https://docs.gradle.org/current/userguide/plugins_intermediate.html Applies the 'com.example.hello' plugin to the 'hello-a' subproject. ```kotlin plugins { id("com.example.hello") } ``` -------------------------------- ### getAsBytes API Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.process/-exec-output/-standard-stream-content/get-as-bytes.html Provides a provider for the standard stream's content as a byte array. The external process is executed only once and only when the value is requested for the first time. If starting the process results in an exception, then the ensuing exception is permanently propagated to callers of get, getOrElse, and getOrNull, and isPresent. ```APIDOC ## getAsBytes() ### Description Gets a provider for the standard stream's content that returns it as a byte array. ### Method GET ### Endpoint /websites/gradle_current/getAsBytes ### Parameters #### Query Parameters - **source** (string) - Required - The source of the stream. ### Response #### Success Response (200) - **bytes** (Array) - The content of the stream as a byte array. #### Response Example { "bytes": [1, 2, 3, 4, 5] } ``` -------------------------------- ### Get Maximum Worker Count Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.concurrent/-parallelism-configuration/get-max-worker-count.html Retrieves the maximum number of concurrent workers used for underlying build operations. Workers can be threads, processes, or other entities that Gradle considers a 'worker'. Examples include threads running tasks, test processes, or language compilers in forked processes. The default value is the number of processors available to the Java virtual machine. ```APIDOC ## GET /gradle/worker/max ### Description Returns the maximum number of concurrent workers used for underlying build operations. ### Method GET ### Endpoint /gradle/worker/max ### Return maximum number of concurrent workers, always >= 1. ### See also Runtime ``` -------------------------------- ### Executing Gradle with profile properties Source: https://docs.gradle.org/current/userguide/migrating_from_maven.html Command line examples for triggering the greeting task with and without specific build profiles. ```bash $ ./gradlew gradle greeting ``` ```text foobar ``` ```bash $ ./gradlew -PbuildProfile=test greeting ``` ```text testing 1 2 3 ``` -------------------------------- ### Check Gradle Installation Source: https://docs.gradle.org/current/userguide/installation.html Run this command in your terminal to check if Gradle is already installed on your system. If it returns nothing, Gradle is not installed. ```bash gradle -v ``` -------------------------------- ### Initialize Gradle Plugin Project Source: https://docs.gradle.org/current/userguide/part3_multi_project_builds.html Commands to initialize the plugin project with the required DSL. ```bash $ gradle init --dsl kotlin --type kotlin-gradle-plugin --project-name license ``` ```bash $ gradle init --dsl groovy --type groovy-gradle-plugin --project-name license ``` -------------------------------- ### Project Structure Example Source: https://docs.gradle.org/current/userguide/gradle_basics.html Illustrates a typical Gradle project layout, including directories for Gradle files, wrapper scripts, settings, build scripts, and source code. ```plaintext project ├── gradle __**(1)** ├── gradlew __**(2)** ├── gradlew.bat __**(2)** ├── settings.gradle(.kts) __**(3)** ├── subproject-a │ ├── build.gradle(.kts) __**(4)** │ └── src/ __**(5)** └── subproject-b ├── build.gradle(.kts) __**(4)** └── src/ __**(5)** ``` -------------------------------- ### Install Executable Task Source: https://docs.gradle.org/current/javadoc/overview-tree.html Task for installing an executable. ```APIDOC ## Install Executable Task ### Native Platform - **org.gradle.nativeplatform.tasks.InstallExecutable**: Task to install an executable. ``` -------------------------------- ### Install XCTest Bundle Task Source: https://docs.gradle.org/current/javadoc/overview-tree.html Task for installing an XCTest bundle. ```APIDOC ## Install XCTest Bundle Task ### Testing - **org.gradle.nativeplatform.test.xctest.tasks.InstallXCTestBundle**: Task to install an XCTest bundle. ``` -------------------------------- ### Project Structure Example Source: https://docs.gradle.org/current/userguide/implementing_custom_tasks.html Illustrates the typical project structure for a Gradle project with Kotlin DSL. ```gradle gradle-project ├── app │ ├── build.gradle.kts // app build logic │ ├── run.sh // script file │ └── ... // some java code ├── settings.gradle.kts // includes app subproject ├── gradle ├── gradlew └── gradlew.bat ``` -------------------------------- ### Apply Specific Plugin in hello-a/build.gradle Source: https://docs.gradle.org/current/userguide/plugins_intermediate.html Applies the 'com.example.hello' plugin to the 'hello-a' subproject using Groovy syntax. ```groovy plugins { id 'com.example.hello' } ``` -------------------------------- ### Get Specific Type with 'getting' DSL Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.kotlin.dsl/getting.html Provides a property delegate that gets elements of a specific type from a container. This is useful when you need to access an element by its type without immediate configuration. ```kotlin fun NamedDomainObjectContainer.getting( type: KClass): PolymorphicDomainObjectContainerGettingDelegateProvider(source) ``` -------------------------------- ### Get and Configure Specific Type with 'getting' DSL Source: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.kotlin.dsl/getting.html Provides a property delegate that gets elements of a specific type from a container and applies a given configuration to them. Requires the element type to be known. ```kotlin fun NamedDomainObjectContainer.getting( type: KClass, configuration: U.() -> Unit): PolymorphicDomainObjectContainerGettingDelegateProvider(source) ``` -------------------------------- ### Project structure examples Source: https://docs.gradle.org/current/userguide/more_about_tasks.html Visual representation of a basic Gradle project structure. ```text gradle-project ├── app │ ├── build.gradle.kts // empty file - no build logic │ └── ... // some java code ├── settings.gradle.kts // includes app subproject ├── gradle │ └── ... ├── gradlew └── gradlew.bat ``` ```text gradle-project ├── app │ ├── build.gradle // empty file - no build logic │ └── ... // some java code ├── settings.gradle // includes app subproject ├── gradle │ └── ... ├── gradlew └── gradlew.bat ``` -------------------------------- ### Build a project Source: https://docs.gradle.org/current/userguide/migrating_from_maven.html Execute the build process to run tests and produce artifacts after migration. ```bash > gradle build ``` -------------------------------- ### Verify Gradle Installation Source: https://docs.gradle.org/current/userguide/installation.html Command to check the installed version and the expected output. ```bash $ gradle -v ``` ```text ------------------------------------------------------------ Gradle 9.0.0 ------------------------------------------------------------ Build time: 2025-07-17 12:48:00 UTC Revision: 2db9560bb68c367a265b10516c856c840f9bed8d Kotlin: 2.2.0 Groovy: 4.0.28 Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024 Launcher JVM: 17.0.11 (Amazon.com Inc. 17.0.11+9-LTS) Daemon JVM: Compatible with Java 17, any vendor, nativeImageCapable=false (from gradle/gradle-daemon-jvm.properties) OS: Mac OS X 14.7.4 aarch64 ```