Giter Site home page Giter Site logo

gradle-publish-mapping's Introduction

Publish Mapping plugin for gradle Build Status Download

Why?

We created Publish Mapping because Gradle, by default, publishes all publications to all publishing repositories. This may not always be wanted.

How does it work?

This plugin works by disabling/removing the publish tasks that publish the publications to the wrong publish repository. It only understands tasks added by the ivy-publish and maven-publish plugins.

Adding to Gradle

buildscript {
	repositories {
		maven {
			url "http://dl.bintray.com/palantir/releases"
		}
		mavenCentral()
	}
	dependencies {
		classpath 'com.palantir:publish-mapping:2.0.0'
	}
}

apply plugin: 'ivy-publish' // or 'maven-publish'
apply plugin: 'publish-mapping'

Usage

The publish.mapping extension allows the project to specify which repositories (from publishing.repositories) each publication (from publishing.publications) should be published to. It does this by disabling the publish tasks that don't match the publish mapping. By default if a publication does not have an entry in the mapping, it will be published to all repositories by the publish task.

  • put(String publicationName, List<String> repositoryNames) - Set a mapping entry
  • add(String publicationName, List<String> repositoryNames) - Create a new or append to an existing mapping entry
publish.mapping {
  put 'PublicationName', ['RepositoryName1', 'RepositoryName2',...] // set a mapping entry
  add 'PublicationName', ['RepositoryName3', ...] // create a new mapping entry or append to an existing one
}

The following example shows how to specify that the publication ‘aaa’ should only be published to repositories ‘xxx’ and ‘yyy’, the publication ‘bbb’ should not be published to any repository, and the publication ‘ccc’ should be published to all repositories.

publishing {
  repositories {
    ivy {
      name 'xxx'
    }
    ivy {
      name 'yyy'
    }
    ivy {
      name 'zzz'
    }
  }
  publications {
    aaa(IvyPublication)
    bbb(IvyPublication)
    ccc(IvyPublication)
  }
}
publish.mapping {
  put 'aaa', ['xxx', 'yyy'] // 'aaa' is only published to repositories 'xxx' and 'yyy'
  put 'bbb', [] // 'bbb' is not published to any repository
  // by default 'ccc' is published to all repositories
}

Run the provided printPublishTasks task to see the expected behavior:

$ ./gradlew printPublishTasks
:printPublishTasks
Publish tasks run by 'publish':
-------------------------------
publishCccPublicationToZzzRepository
publishCccPublicationToYyyRepository
publishAaaPublicationToXxxRepository
publishAaaPublicationToYyyRepository
publishCccPublicationToXxxRepository

Publish tasks skipped by 'publish':
-----------------------------------
publishBbbPublicationToXxxRepository
publishBbbPublicationToYyyRepository
publishAaaPublicationToZzzRepository
publishBbbPublicationToZzzRepository

BUILD SUCCESSFUL

Version Compatibility

Sometimes Gradle changes the way tasks and publishing is implemented. This table maps publish-mapping versions to compatible Gradle versions.

publish-mapping version Gradle version Notes
[1.1.0, 2.0.0) 2.2.1  
[2.0.0, ) 2.4, 2.5, 2.6  

LICENSE

Gradle Flex Version is released by Palantir Technologies, Inc. under the Apache 2.0 License. see the included LICENSE file for details.

gradle-publish-mapping's People

Contributors

kostasniktas avatar natgabb avatar atrocities avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.