Skip to content

IntershopCommunicationsAG/nexusstaging-gradle-plugin

Repository files navigation

Nexus Staging Gradle Plugin

Summary

This plugin transfer a set of modules to a Sonatype Nexus staging repository. The modules can be stored in an Ivy or Maven repository. So it is possible to handle the complete result of a Gradle multi project build in one staging repository of a Sonatype Nexus Pro instance.

Usage

To apply the Nexus Staging Plugin to your project, add the following in your build script:

plugins {
    id 'com.intershop.gradle.nexusstaging' version '2.2.0'
}

nexusStaging {
    server {
        baseURL = <Sonataype Nexus Parse URL>
        username = <user name>
        password =  <password>
    }

    repositoryDir = <path to local repository>
    description = <description for the respoitory>
    resultPropertiesFile = <file path to a property file>
    publications = ['myIvyPublication']
}

This plugin adds a task to the project for copying a local file repositry to a Sonatype Nexus staging respository. It creates also an "closeRepo" task, which closes all open Tasks based on the info on the filesystem. Snapshot versions will be ignored and not handled by this plugin.

This functionality is only available with Sonatype Nexus Repository.

Tasks

The Nesus Staging Plugin plugin adds two tasks to the project.

Task name Type Description

upload

com.intershop.gradle.nexusstaging.tasks.CopyToRepos

This task copy the local repository data to a Sonatype Nexus Staging repository and closes this repositories.
The main 'publish' task depends on the this task. This task is always executed if the configuration for server is complete, 'runOnCI' is true and the directory 'repositoryDir' exists.

closeRepo

com.intershop.gradle.nexusstaging.tasks.CloseRepos

This task closes open repositories. It depends on the upload task.
It will be executed if the server configuration is complete and 'runOnCI' is true.

Project Extension 'nexusStaging'

This plugin adds an extension nexusStaging to the project.

Methods

Method Values Description

server

server

This contains the Nexus server connection configuration.

Properties

Property Type Default value Description

repositoryDir

File

'<build dir>/staging/repo'

Directory with local publication.

description

String

'<project name> transfer to repo for version <project version>"

Description for the staging repository

resultPropertiesFile

File

'<build dir>/staging/results/repotransfer.properties'

Properties with information from transfer result.

runOnCI

boolean

false

Server configuration 'Server'

Property Type Default value Description

baseURL

String

Sonatype Nexus base URL

username

String

Username for Sonatype Nexus Repository

password

String

Password for Sonatype Nexus Repository

Repository Configurations

The configured repositoryDir will be added to the repository configurations, if the new Maven publish plugin is applied as a Maven repository and if the new Ivy publish plugin is applied as Ivy repository. The repository will be added to publications if the name is included in publications. The name of the repository configuration is ivyNexusStaging or mvnNexusStaging.

Environment Configuration

The behaviour of this plugin can be also controlled by environment variables, so that the plugin can be applied to the project without exceptions.

System variable or Java system property Project property Description

RUNONCI

runOnCI

This configuration must be true, if the project is used on a CI server.

NEXUSBASEURL

nexusBaseURL

The base url of the repository server, e.g. http://nexus/nexus

NEXUSUSERNAME

nexusUserName

The username with the correct role/permissions for transfer

NEXUSUSERPASSWD

nexusUserPASSWD

The password of the user.

License

Copyright 2014-2016 Intershop Communications.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.