You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.4 KiB
Plaintext
96 lines
3.4 KiB
Plaintext
=== Getting Started
|
|
|
|
[source,groovy,subs="+attributes"]
|
|
----
|
|
buildscript {
|
|
repositories {
|
|
jcenter()
|
|
}
|
|
dependencies {
|
|
classpath 'org.xbib.gradle.plugin:gradle-plugin-shadow:{project-version}'
|
|
}
|
|
}
|
|
|
|
apply plugin: 'java'
|
|
apply plugin: 'org.xbib.gradle.plugin.shadow'
|
|
----
|
|
|
|
Alternatively, the Gradle Plugin syntax can be used:
|
|
|
|
[source,groovy,subs="+attributes"]
|
|
----
|
|
plugins {
|
|
id 'java'
|
|
id 'org.xbib.gradle.plugin.shadow' version '{project-version}'
|
|
}
|
|
----
|
|
|
|
Shadow is a reactive plugin.
|
|
This means that applying Shadow by itself will perform no configuration on your project.
|
|
Instead, Shadow __reacts__ to the application of other plugins to decorate the project.
|
|
|
|
This means, that for most users, the `java` or `groovy` plugins must be __explicitly__ applied
|
|
to have the desired effect.
|
|
|
|
=== Default Java/Groovy Tasks
|
|
|
|
In the presence of the `java` or `groovy` plugins, Shadow will automatically configure the
|
|
following behavior:
|
|
|
|
* Adds a `shadowJar` task to the project.
|
|
* Adds a `shadow` configuration to the project.
|
|
* Configures the `shadowJar` task to include all sources from the project's `main` sourceSet.
|
|
* Configures the `shadowJar` task to bundle all dependencies from the `runtime` configuration.
|
|
* Configures the __classifier__ attribute of the `shadowJar` task to be `'all'` .
|
|
* Configures the `shadowJar` task to generate a `Manifest` with:
|
|
** Inheriting all configuration from the standard `jar` task.
|
|
** Adds a `Class-Path` attribute to the `Manifest` that appends all dependencies from the `shadow` configuration
|
|
* Configures the `shadowJar` task to __exclude__ any JAR index or cryptographic signature files matching the following patterns:
|
|
** `META-INF/INDEX.LIST`
|
|
** `META-INF/*.SF`
|
|
** `META-INF/*.DSA`
|
|
** `META-INF/*.RSA`
|
|
* Creates and registers the `shadow` component in the project (used for integrating with `maven-publish`).
|
|
* Configures the `uploadShadow` task (as part of the `maven` plugin) with the following behavior:
|
|
** Removes the `compile` and `runtime` configurations from the `pom.xml` file mapping.
|
|
** Adds the `shadow` configuration to the `pom.xml` file as `RUNTIME` scope.
|
|
|
|
=== Shadowing Gradle Plugins
|
|
|
|
Shadow is capable of automatically configuring package relocation for your dependencies.
|
|
This is useful especially when building Gradle plugins where you want your dependencies to not conflict with versions
|
|
provided by the Gradle runtime.
|
|
|
|
[source,groovy,subs="+attributes"]
|
|
----
|
|
buildscript {
|
|
repositories {
|
|
jcenter()
|
|
}
|
|
dependencies {
|
|
classpath 'org.xbib.gradle.plugin:shadow:{project-version}'
|
|
}
|
|
}
|
|
|
|
apply plugin: 'org.xbib.gradle.plugin.shadow'
|
|
apply plugin: 'java'
|
|
----
|
|
|
|
Alternatively, the Gradle Plugin syntax can be used:
|
|
|
|
[source,groovy,subs="+attributes"]
|
|
----
|
|
plugins {
|
|
id 'java'
|
|
id 'org.xbib.gradle.plugin.plugin-shadow' version '{project-version}'
|
|
}
|
|
----
|
|
|
|
Applying the `plugin-shadow` plugin is the same as applying the standard `shadow` plugin with the additional creation
|
|
of the `configureRelocationShadowJar` task.
|
|
This task runs before the `shadowJar` task and scans the packages present in the dependencies that will be merged into
|
|
the final jar and automatically configures relocation for them.
|
|
By default the tasks relocates all packages to the `shadow.` prefix.
|
|
For example `org.jdom2.JDOMException` becomes `shadow.org.jdom2.JDOMException`
|
|
|
|
For more details see the sectinon <<Using Shadow to Package Gradle Plugins>> |