Gradle's real achitecture

Gradle's real architecture

Search for: Gradle's real architecture

Steep learning curve: critical look at Gradle as a build system

Gradle project, plugin and task interaction

Search for: Gradle project, plugin and task interaction

may be in youtube videos

videos really slows down learning (for me)

How to projects, plugins, and tasks interact?

what is configured?

What is executed?

What is gradle's philosophy and architecture?

The how, that explains how it ticks?

By knowing what everything else derives meaning?

perhaps understanding its plugins makes this clear

Convention

Execution (via tasks) assuming convention

Configuring execution to (to describe dependencies or altering convention)

Very early I warn

what are the basic entities of gradle

Search for: what are the basic entities of gradle

Tasks:Search On Web

Configurations:Search On Web

Dependencies:Search On Web

Artifacts:Search On Web

Repositories:Search On Web

Configurations are described here

Dependencies are explained here

Gradle GMV syntax explanation

Search for: Gradle GMV syntax explanation

A build script developer can declare dependencies for different scopes e.g. just for compilation of source code or for executing tests. In Gradle, the scope of a dependency is called a configuration

If you declare a module dependency, Gradle looks for a module metadata file (.module, .pom or ivy.xml) in the repositories. If such a module metadata file exists, it is parsed and the artifacts of this module (e.g. hibernate-3.0.5.jar) as well as its dependencies (e.g. cglib) are downloaded. If no such module metadata file exists, Gradle may look, depending on the metadata sources definitions, for an artifact file called hibernate-3.0.5.jar directly. In Maven, a module can have one and only one artifact. In Gradle and Ivy, a module can have multiple artifacts. Each artifact can have a different set of dependencies.

Gradle configurations compile runtime, where are these defined?

Search for: Gradle configurations compile runtime, where are these defined?

For the java plugin these are documented here

How can I add a local jar file as a gradle dependency?

Search for: How can I add a local jar file as a gradle dependency?


apply plugin: 'java'
//so that we can use 'compile', 'testCompile' for dependencies

dependencies {
  //for dependencies found in artifact repositories you can use
  //the group:name:version notation
  compile 'commons-lang:commons-lang:2.6'
  testCompile 'org.mockito:mockito:1.9.0-rc1'

  //map-style notation:
  compile group: 'com.google.code.guice', name: 'guice', version: '1.0'

  //declaring arbitrary files as dependencies
  compile files('hibernate.jar', 'libs/spring.jar')

  //putting all jars from 'libs' onto compile classpath
  compile fileTree('libs')
}

Here is an interesting way of using project extensions

Define a class with executable methods that can operate on any aspect of Gradle build

Register the class with Gradle as an extension

You can execute methods of that class as a closure whose delegate is that class instance

Dependency object hierarchy


org.gradle.api.artifacts.ExternalDependency
  isForce, setForce, version

org.gradle.api.artifacts.ModuleDependency
 addArtifact, artifact, artifact, attributes, 
 exclude, getArtifacts, getAttributes, 
 getExcludeRules, getTargetConfiguration, isTransitive, 
 setTargetConfiguration, setTransitive

org.gradle.api.artifacts.Dependency
 because, contentEquals, getGroup, 
 getName, getReason, getVersion

org.gradle.api.artifacts.ModuleVersionSelector
 getGroup, getModule, getName, 
 getVersion, getVersionConstraint, matchesStrictly

Type of dependencies are documented in DependencyHandler API


External library
Other projects
Files
Other configurations
Gradle dependencies
Client module dependencies

Here is how to work with files in Gradle

Here is a chapter of a book on dependencies

is classpath a gradle dependency configuration name?

Search for: is classpath a gradle dependency configuration name?

Here is more on this

Here is a - slightly - better explanation of "classpath" as a configuration

Dependency terminology