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.
gradle-plugins/gradle-plugin-shadow/src/docs/asciidoc/40-publishing.adoc

70 lines
2.1 KiB
Plaintext

== Publishing Shadow JARs
=== Publishing with Maven-Publish Plugin
The Shadow plugin will automatically configure the necessary tasks in the presence of Gradle's
`maven-publish` plugin.
The plugin provides the `component` method from the `shadow` extension to configure the
publication with the necessary artifact and dependencies in the POM file.
.Publishing a Shadow JAR with the Maven-Publish Plugin
[source,groovy,indent=0]
----
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'org.xbib.plugin.gradle.shadow'
publishing {
publications {
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
}
}
repositories {
maven {
url "http://repo.myorg.com"
}
}
}
----
=== Publishing with Maven Plugin
The Shadow plugin will automatically configure the necessary tasks in the presence of Gradle's
`maven` plugin.
To publish the JAR, simply configure the publish location for the `uploadShadow` task and execute it.
.Publishing a Shadow JAR with the Maven Plugin
[source,groovy,indent=0]
----
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'org.xbib.gradle.plugin.shadow'
uploadShadow {
repositories {
mavenDeployer {
repository(url: "http://repo.myorg.com")
}
}
}
----
=== Shadow Configuration and Publishing
The Shadow plugin provides a custom configuration (`configurations.shadow`) to specify
runtime dependencies that are *not* merged into the final JAR file.
When configuring publishing with the Shadow plugin, the dependencies in the `shadow`
configuration, are translated to become `RUNTIME` scoped dependencies of the
published artifact.
No other dependencies are automatically configured for inclusion in the POM file.
For example, excluded dependencies are *not* automatically added to the POM file or
if the configuration for merging are modified by specifying
`shadowJar.configurations = [configurations.myconfiguration]`, there is no automatic
configuration of the POM file.
This automatic configuration occurs _only_ when using the above methods for
configuring publishing. If this behavior is not desirable, then publishing *must*
be manually configured.