jenkinsci / gradle-jpi-plugin

Build Jenkins Plugins with Gradle
79 stars 50 forks source link

Use the plugin only to "unpack" Jenkins dependencies for external projects #191

Closed rsayn closed 3 years ago

rsayn commented 3 years ago

Feature Request

Hello, I'm trying to develop a Jenkins-related Gradle plugin to perform some custom build steps on some code. To do so, I need to have some of the Jenkins core libraries and plugins as dependencies which are available in HPI / JPI format. I've tried declaring dependencies with an explicit @jar suffix, as follows:

dependencies {
    implementation 'org.jenkins-ci.main:jenkins-core:2.164.1@jar'
    implementation 'org.jenkins-ci.plugins.workflow:workflow-step-api:2.23@jar'
}

This causes the build to fail since some of the sub-dependencies of the two artifacts seem to be missing (stuff like javax.servlet API), and I would have to add them all manually. By using the gradle-jpi-plugin I am able to retrieve said dependencies automatically and the build works fine, but I don't actually need to build a fully-featured Jenkins plugin; I was wondering if there was a way to use your plugin only to "unpack" Jenkins dependencies.

Thanks

sghill commented 3 years ago

Hi @rsayn,

I was wondering if there was a way to use your plugin only to "unpack" Jenkins dependencies.

Yes. This would use the JpiVariantRule.

You'll need the plugin on your buildscript classpath (or define a similar rule in your project), and then you can apply it with

dependencies {
     components.all(org.jenkinsci.gradle.plugins.jpi.JpiVariantRule)
}
rsayn commented 3 years ago

Hi, sorry for the late response. I was able to setup a base skeleton project that does what I was looking for, but I will try this solution as well. Thanks a lot!