Code Monkey home page Code Monkey logo

gradle-maven-settings-plugin's Introduction

Gradle Maven settings plugin

This Gradle plugin provides a migration path for projects coming from a Maven ecosystem. It exposes standard Maven configuration located in settings files to your Gradle project. This allows projects to continue to leverage functionality provided by Maven such as mirrors as well use existing settings configuration to store encrypted repository authentication credentials.

Usage

To use the plugin, add the following to your build.gradle file.

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    
    dependencies {
        classpath 'net.linguica.gradle:maven-settings-plugin:0.4'
    }
}

apply plugin: 'net.linguica.maven-settings'

For Gradle 2.1+ you can use the new plugin mechanism to download the plugin from the Gradle Plugin Portal.

plugins {
  id "net.linguica.maven-settings" version "0.4"
}

Mirrors

The plugin exposes Maven-like mirror capabilities. The plugin will properly register and enforce any mirrors defined in a settings.xml with <mirrorOf> values of *, external:* or central. Existing repositories {...} definitions that match these identifiers will be removed.

Credentials

The plugin will attempt to apply credentials located in <server> elements to appropriate Maven repository definitions in your build script. This is done by matching the <id> element in the settings.xml file to the name property of the repository definition.

repositories {
    maven {
        name = 'myRepo' // should match <id>myRepo</id> of appropriate <server> in settings.xml
        url = 'https://intranet.foo.org/repo'
    }
}

Server credentials are used for mirrors as well. When mirrors are added the plugin will look for a <server> element with the same <id> and the configured credentials are used and decrypted if necessary.

Publishing

The plugin will also attempt to apply credentials to repositories configured using the 'maven-publish' plugin.

publishing {
    repositories {
        maven {
            name = 'myRepo' // should match <id>myRepo</id> of appropriate <server> in settings.xml
            url = 'https://intranet.foo.org/repo/repositories/releases'
        }
    }
}

Note: Currently only Basic Authentication using username and password is supported at this time.

Profiles

Profiles defined in a settings.xml will have their properties exported to the Gradle project when the profile is considered active. Active profiles are those listed in the <activeProfiles> section of the settings.xml, the activeProfiles property of the mavenSettings {...} configuration closure, or those that satisfy the given profile's <activation> criteria.

Configuration

Configuration of the Maven settings plugin is done via the mavenSettings {...} configuration closure. The following properties are available.

  • userSettingsFileName - String representing the path of the file to be used as the user settings file. This defaults to '$USER_HOME/.m2/settings.xml'
  • activeProfiles - List of profile ids to treat as active.
  • exportGradleProps - Flag indicating whether or not Gradle project properties should be exported for the purposes of settings file property interpolation and profile activation. This defaults to true.

gradle-maven-settings-plugin's People

Contributors

mark-vieira 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.