Gradle Operations TODEPLETE: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 49: Line 49:
* a project-level [[Gradle_Configuration#Project-Level_.27.gradle.27_Directory|.gradle]] directory
* a project-level [[Gradle_Configuration#Project-Level_.27.gradle.27_Directory|.gradle]] directory
* [[Gradle_Concepts#The_Gradle_Wrapper|gradlew]], [[Gradle_Concepts#The_Gradle_Wrapper|gradlew.bat]]
* [[Gradle_Concepts#The_Gradle_Wrapper|gradlew]], [[Gradle_Concepts#The_Gradle_Wrapper|gradlew.bat]]
===Gradle Project Initialization Script===
{{External|https://github.com/NovaOrdis/playground/blob/master/project-template-gradle/gradle-init}}


==List Sub-Projects==
==List Sub-Projects==

Revision as of 07:28, 1 June 2018

Internal

Overview

Command Line

Some command line options have the same effect as setting corresponding properties or environment variables. When a command line option is present, it has precedence over the equivalent properties or environment variables. More details in Gradle Variables and Properties.

gradle --help

-q, --quiet

Quiet.

-m, --dry-run

Executes a dry run.

-D, --system-prop

System Properties

--build-cache

Runtime Configuration

Various aspects of the runtime configuration are controlled with Gradle properties:

  • org.gradle.console: console output coloring and verbosity.
  • org.gradle.debug: starts the JVM in debug mode, listening on port 5005. This is equivalent with adding the following on the JVM command line:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

Operations

Start a Project

gradle init

Creates a project structure that includes:

Gradle Project Initialization Script

https://github.com/NovaOrdis/playground/blob/master/project-template-gradle/gradle-init

List Sub-Projects

gradle projects

Inspect Dependencies

https://docs.gradle.org/current/userguide/inspecting_dependencies.html

The full graph of the project's dependencies can be rendered. The selection reason and origin for a dependency can also be displayed.

To display the dependency trees for all dependency configurations of the project, execute:

gradle -q dependencies

The result is called a dependency report. Any dependency that could not be resolved is marked with FAILED in red color. Dependencies with the same coordinates that can occur multiple times in the graph are omitted and indicated by an asterisk. Dependencies that had to undergo conflict resolution render the requested and selected version separated by a right arrow character. The dependency report provides the raw list of dependencies but does not explain why they have been selected or which dependency is responsible for pulling them into the graph. These explanations can though be generated, see Identify Why a Specific Dependency was Selected.

To display the dependency tree for just one dependency configuration:

gradle -q dependencies --configuration <configuration-name>

Identify Why a Specific Dependency was Selected

gradle -q dependencyInsight --dependency <dependency-name> [--configuration <configuration-name>]

Print the Runtime Classpath

task printClasspath {
        doLast {
            configurations.runtimeClasspath.each { print it; print ':' }
        }
}

Then Gradle must be run with "-q" option to discard extraneous output:

gradle -q printClasspath

Artifact Publishing Operations

Artifact Publishing Operations

Command-Line Interface

https://docs.gradle.org/current/userguide/command_line_interface.html

Tasks

build

Build without tests. Works with simple projects or multi-project builds.

gradle build -x test
gradle build -x :some-project:test

Build a sub-project:

gradle :<sub-project-name>:build

projects

gradle projects

tasks

Displaying Tasks

properties

Displays project properties, properties added by various plugins and their default values.

gradle properties