DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. Gradle Goodness: Custom Plugin Repositories With Plugins DSL

Gradle Goodness: Custom Plugin Repositories With Plugins DSL

Learn more about hosting your own plugin repo on a company intranet.

Hubert Klein Ikkink user avatar by
Hubert Klein Ikkink
·
Nov. 09, 16 · Tutorial
Like (3)
Save
Tweet
Share
9.36K Views

Join the DZone community and get the full member experience.

Join For Free

To apply a plugin in our Gradle build script, we can use the plugins DSL. The plugins DSL is very concise and allows Gradle to be more efficient and more in control when loading the plugin. Normally the plugin we define is fetched from the Gradle plugin portal. If we have our own repository, for example on the intranet of our company, we have to define that extra repository with a pluginRepositories configuration block in the settings.gradle file of our project.

In the following sample, we have a plugin mrhaki.gradle.version-file that is stored in the company intranet repository with the URL http://intranet/artifactory/libs-release/.

// File: settings.gradle
// As the first statement of the settings.gradle file
// we can define pluginRepositories:
pluginRepositories {
    maven { url 'http://intranet/artifactory/libs-release/' }
    gradlePluginPortal() // Include public Gradle plugin portal
}

In our build file we use the plugins DSL to apply the mrhaki.gradle.version-file plugin:

// File: build.gradle
plugins {
    id 'mrhaki.gradle.version-file' version '1.2.2'
}


There is a restriction when we use this approach. The plugin must be deployed to our intranet repository with plugin marker artifacts. Gradle needs these to resolve the value for id to the correct plugin. A plugin marker artifact is a deployment following a specific naming convention with a dependency on the actual plugin code. If we write our own plugin we best can use the java-gradle-plugin (Java Gradle Plugin Development Plugin), which automatically adds the plugin marker artifacts when we publish our plugin to the intranet repository.

We could also have used the buildscript configuration block in our build.gradle file to define a custom repository for our plugin. Inside the buildscript configuration we use the repositories block to add our intranet repository. But than we cannot use the plugins DSL, but have to use the apply plugin: syntax.

Written with Gradle 3.1.

Domain-Specific Language Repository (version control) Gradle

Published at DZone with permission of Hubert Klein Ikkink, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Unlocking the Power of Polymorphism in JavaScript: A Deep Dive
  • Last Chance To Take the DZone 2023 DevOps Survey and Win $250! [Closes on 1/25 at 8 AM]
  • A Real-Time Supply Chain Control Tower Powered by Kafka
  • Java Development Trends 2023

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: