Dev Publish is a Gradle plugin that publishes subprojects to a project-local directory, ready for functional testing.
- Create a project local repository for testing only your publications
- Avoid using Maven Local (see: "you should avoid adding mavenLocal() as a repository")
- Perfect for testing Gradle plugins and
Gradle Plugin Marker Artifacts
(instead of using TestKit +
withRuntimeClasspath()
) - Avoids unnecessary re-publishing (even if using SNAPSHOT versions)
- Compatible with Gradle Build and Configuration cache
If a subproject already publishes Maven artifacts, then apply DevPublish using the plugin ID dev.adamko.dev-publish
and the latest version.
// build.gradle.kts
plugins {
`maven-publish`
id("dev.adamko.dev-publish") version "$devPublishPluginVersion>"
}
Any project can depend on publications from other subprojects
// build.gradle.kts
plugins {
id("dev.adamko.dev-publish")
}
dependencies {
devPublication(project(":some-other-subproject"))
}
Dev Publish is great for cross-project publications.
Given multiple subprojects:
.
└── root/
├── my-java-library/
│ └── build.gradle.kts
│
├── my-kotlin-application/
│ └── build.gradle.kts
│
└── functional-tests/
└── build.gradle.kts
Both the 'Java library' and 'Kotlin application' subprojects publish using the Maven Publish Plugin.
// my-java-library/build.gradle.kts
plugins {
`java-library`
`maven-publish`
id("dev.adamko.dev-publish")
}
// my-kotlin-application/build.gradle.kts
plugins {
application
kotlin("jvm")
`maven-publish`
id("dev.adamko.dev-publish")
}
The 'functional-tests' subproject can aggregate the publications and collect them into a project-local directory, ready for testing.
// functional-tests/build.gradle.kts
plugins {
id("dev.adamko.dev-publish")
}
dependencies {
devPublication(project(":my-java-library"))
devPublication(project(":my-kotlin-application"))
}
tasks.test {
// will publish all publications from
// :my-java-library and :my-kotlin-application
// into the `devPublish.devMavenRepo` directory
dependsOn(tasks.updateDevRepo)
// provide devMavenRepo for use in tests
environment(
"MAVEN_DEV_REPO" to devPublish.devMavenRepo.asFile.get().invariantSeparatorsPath
)
}