https://github.com/rainbowdashlabs/publishdata
Gradle plugin used to avoid boilerplate code for release detection on my projects
https://github.com/rainbowdashlabs/publishdata
developer-tools devops gradle-plugin
Last synced: 5 months ago
JSON representation
Gradle plugin used to avoid boilerplate code for release detection on my projects
- Host: GitHub
- URL: https://github.com/rainbowdashlabs/publishdata
- Owner: rainbowdashlabs
- Created: 2021-11-07T11:57:37.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-27T16:12:51.000Z (6 months ago)
- Last Synced: 2024-11-27T17:24:13.923Z (6 months ago)
- Topics: developer-tools, devops, gradle-plugin
- Language: Kotlin
- Homepage:
- Size: 182 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README

 \


Small gradle plugin which I use to avoid boilerplate code for version detection.
This util helps to publish artifacts, sets the correction version with optional commit hash and branch identifier and
chooses the repository based on the current branch.## Setup
### settings.gradle.kts
Add the eldonexus as a plugin repository
```kotlin
pluginManagement {
repositories {
maven("https://eldonexus.de/repository/maven-public/")
}
}
```### build.gradle.kts
#### General
Apply the publishdata as a plugin
```
plugins {
id("de.chojo.publishdata") version "version"
}
```Basic configuration which tasks you want to publish
```kt
publishData {
// Add tasks which should be published
publishTask("jar")
publishTask("sourcesJar")
publishTask("javadocJar")
}
```Additional publishData can generate a `build.data` file which contains information about the build itself.
```
time=ISO 8601 formatted timestamp
unix=unix timestamp of build time
type=build type
branch=branch
commit=commit hash
artifactVersion=version
artifact=artifact name
runtime=java runtime used to build
```To enable that simply add this to your configuration
```kt
publishData {
addBuildData()
}
```This function also accepts a map to add additional values.
#### Adding repositories
You have to define repositories like that or chose the eldonexus or gitlab configuration below:```kt
publishData {
// manually register a release repo for main branch
addMainRepo("https://my-repo.com/releases")
// manually register a snapshot repo which will append -SNAPSHOT+
addSnapshotRepo("https://my-repo.com/snapshots")
}publishing {
publications.create("maven") {
// configure the publication as defined previously.
publishData.configurePublication(this)
}repositories {
maven {
authentication {
// Auth for the repository
// ....
}name = "MyRepo"
// Get the detected repository from the publishData
url = uri(publishData.getRepository())
}
}
}
```Make sure to declare them in the correct order. PublishData will take the first applicable repository.
#### Eldonexus
Additionaly call this in the configuration to publish to the eldonexus.
This will preconfigure for main, master, dev and snapshot branches.```kt
publishData {
// only if you want to publish to the eldonexus. If you call this you will not need to manually add repositories
useEldoNexusRepos()
}
```#### GitLab
Additionaly call this in the configuration to publish to a gitlab repository and replace your repository declaration.```kt
publishData {
// only if you want to publish to the gitlab. If you call this you will not need to manually add repositories
useGitlabReposForProject("177", "https://gitlab.example.com/")
}publishing {
publications.create("maven") {
// configure the publication as defined previously.
publishData.configurePublication(this)
}repositories {
maven {
credentials(HttpHeaderCredentials::class) {
name = "Job-Token"
value = System.getenv("CI_JOB_TOKEN")
}
authentication {
create("header", HttpHeaderAuthentication::class)
}
name = "Gitlab"
// Get the detected repository from the publish data
url = uri(publishData.getRepository())
}
}
}
```