Gradle Distribution Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 17: Line 17:
=Building Custom Files with the Distribution=
=Building Custom Files with the Distribution=


All files in the ./src/<distribution-name>/dist directory will be automatically included in the distribution.
All files in the ./src/<distribution-name>/dist directory will be automatically included in the distribution. There is always a default "main" distribution.  


Additional files can be added by configuring the [https://docs.gradle.org/4.7/javadoc/org/gradle/api/distribution/Distribution.html Distribution] object:
Additional files can be added by configuring the [https://docs.gradle.org/4.7/javadoc/org/gradle/api/distribution/Distribution.html Distribution] object:
Line 36: Line 36:
</syntaxhighlight>
</syntaxhighlight>


In this example, the content of the "src/readme" directory will be included in the distribution along with the files in "src/main/dist".
In this example, the content of the "src/readme" directory will be included in the distribution along with the files in "src/main/dist". Changing the "baseName"will cause the distribution archives to be created under a different name.


=Multiple Distributions=
=Multiple Distributions=


<font color=darkgray>See "Adding extra distributions" in documentation</font>.
<font color=darkgray>See "Adding extra distributions" in documentation</font>.

Revision as of 22:54, 28 July 2018

External

Internal


Overview

The Distribution plugin builds archives that serve as distributions of the project. They typically contain the executable application and other supporting files, such as the documentation. The Distribution plugin is part of the Application plugin flow. The plugin adds an extension named "distributions" of type DistributionContainer. It also creates a single distribution in the distributions container, named "main". Multiple distributions can be configured.

The distribution files are created in $buildDir/distributions/$project.name-$project.version.<ext>.

Building Custom Files with the Distribution

All files in the ./src/<distribution-name>/dist directory will be automatically included in the distribution. There is always a default "main" distribution.

Additional files can be added by configuring the Distribution object:

apply plugin: 'distribution'

...

distributions {
    main {
        baseName = 'someName'
        contents {
            from { 'src/readme' }
        }
    }
}

In this example, the content of the "src/readme" directory will be included in the distribution along with the files in "src/main/dist". Changing the "baseName"will cause the distribution archives to be created under a different name.

Multiple Distributions

See "Adding extra distributions" in documentation.