Skip to content

The Gradle Plugin

Alex Wood edited this page Jun 29, 2020 · 4 revisions

PDM Gradle Plugin

PDM provides a Gradle plugin that automatically generates a dependencies.json at build time. The latest version can be found here: https://plugins.gradle.org/plugin/me.bristermitten.pdm

From here you can add the plugin itself:

plugins {
    id 'me.bristermitten.pdm' version '0.0.1'
}

Usage

The plugin adds a new configuration named pdm that is used to designate a dependency as being downloaded by PDM. This is used the same way as any other configuration:

dependencies {
    pdm 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72'
}

The plugin also configures the jar task to automatically shade the runtime in, and adds it to the classpath. If you would prefer to use something like Shadow to do this, you can disable it easily:

pdm {
    disableRuntimeBundling()
}

Then, simply run the pdm task to generate a dependencies.json file in build/resources/main. Typically one would combine this with something like build, or run pdm automatically with something like jar.dependsOn project.tasks.getByName('pdm')

The task uses a cache to avoid querying repos every build. This is located in build/tmp/pdm/cache, stored as JSON text. This cache is invalided if the repositories or dependencies of the project change, but can also be overriden with the task pdmGenDependencies, or removed with the clean task.

There are many more options available for the plugin, which can be found here

Clone this wiki locally