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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Code Security Remediation: What 50,000 Repositories Reveal About PR Scanning
  • Shrink a Bloated Git Repository and Optimize Pack Files
  • Jakarta Data in Jakarta EE 12 M2: From Repositories to a Unified Data Access Model
  • Using ChartMuseum as a Helm Repository

Trending

  • Solving the Mystery: Why Java RSS Grows in Docker on M1 Macs
  • Real-Time AI Inference at Scale Using Cloud Run, GPUs, and Vertex AI
  • Key Takeaways From Integrating a RAG Application With LangSmith
  • Beyond Conversation: Mastering Context with Claude Code Skills and Agents
  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.

By 
Hubert Klein Ikkink user avatar
Hubert Klein Ikkink
·
Nov. 09, 16 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
10.3K 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. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Code Security Remediation: What 50,000 Repositories Reveal About PR Scanning
  • Shrink a Bloated Git Repository and Optimize Pack Files
  • Jakarta Data in Jakarta EE 12 M2: From Repositories to a Unified Data Access Model
  • Using ChartMuseum as a Helm Repository

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook