[root] Use gradle kotlin dsl

This commit is contained in:
Johannes Frohnmeyer 2022-11-01 18:55:17 +01:00
parent dd9a465c69
commit f11be52861
Signed by: Johannes
GPG Key ID: E76429612C2929F4
12 changed files with 166 additions and 136 deletions

View File

@ -1,71 +0,0 @@
var cl = Calendar.instance
var day = "${cl.get(cl.YEAR)}.${cl.get(cl.MONTH) + 1}.${cl.get(cl.DATE)}"
var time = "${cl.get(cl.HOUR_OF_DAY)}-${cl.get(cl.MINUTE)}-${cl.get(cl.SECOND)}"
allprojects {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
version = "$day+$time"
repositories {
mavenCentral()
maven {
url 'https://gitlab.com/api/v4/projects/35030495/packages/maven'
}
}
dependencies {
compileOnly 'org.jetbrains:annotations:23.0.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
}
test {
useJUnitPlatform()
}
java {
withSourcesJar()
}
publishing {
def ENV = System.getenv()
if (project.hasProperty("maven")) {
repositories.maven {
url = project.getProperty("maven")
name = "dynamic"
credentials(HttpHeaderCredentials) {
name = "Job-Token"
value = ENV.CI_JOB_TOKEN
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
repositories.mavenLocal()
}
}
subprojects {
dependencies {
implementation project(':')
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'io.gitlab.jfronny'
artifactId = 'commons'
from components.java
}
}
}

22
build.gradle.kts Normal file
View File

@ -0,0 +1,22 @@
import java.util.Calendar
plugins {
id("commons.library")
}
var cl = Calendar.getInstance()
var day = "${cl.get(Calendar.YEAR)}.${cl.get(Calendar.MONTH) + 1}.${cl.get(Calendar.DATE)}"
var time = "${cl.get(Calendar.HOUR_OF_DAY)}-${cl.get(Calendar.MINUTE)}-${cl.get(Calendar.SECOND)}"
version = "$day+$time"
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "io.gitlab.jfronny"
artifactId = "commons"
from(components["java"])
}
}
}

12
buildSrc/build.gradle.kts Normal file
View File

@ -0,0 +1,12 @@
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:2.3.3")
}

View File

@ -0,0 +1,47 @@
plugins {
`java-library`
`maven-publish`
}
version = rootProject.version
repositories {
mavenCentral()
maven("https://gitlab.com/api/v4/projects/35030495/packages/maven")
}
dependencies {
compileOnly("org.jetbrains:annotations:23.0.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
java {
withSourcesJar()
}
publishing {
repositories {
mavenLocal()
if (project.hasProperty("maven")) {
maven {
url = uri(project.property("maven").toString())
name = "dynamic"
credentials(PasswordCredentials::class) {
username = System.getenv()["MAVEN_NAME"]
password = System.getenv()["MAVEN_TOKEN"]
}
authentication {
create<BasicAuthentication>("basic")
}
}
}
}
}

View File

@ -1,32 +0,0 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
}
dependencies {
shadow implementation('io.gitlab.jfronny:gson:2.9.2-20220914.175359-3')
}
shadowJar {
configurations = [ project.configurations.shadow ]
archiveClassifier = ''
relocate 'com.google.gson', 'io.gitlab.jfronny.gson'
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'io.gitlab.jfronny'
artifactId = 'commons-gson'
project.shadow.component(it)
pom.withXml {
asNode().dependencies.dependency.each { dep ->
if(dep.artifactId.last().value() in ["gson"]) {
assert dep.parent().remove(dep)
}
}
}
}
}
}

View File

@ -0,0 +1,37 @@
plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
id("commons.library")
}
dependencies {
shadow(implementation("io.gitlab.jfronny:gson:2.9.2-20220914.175359-3")!!)
implementation(project(":"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}
tasks.shadowJar {
configurations.clear()
configurations.add(project.configurations.shadow.get())
archiveClassifier.set("")
relocate("com.google.gson", "io.gitlab.jfronny.gson")
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "io.gitlab.jfronny"
artifactId = "commons-gson"
project.shadow.component(this)
pom.withXml {
val l = asElement().getElementsByTagName("dependency");
for (i in 0 until l.length) {
l.item(i).parentNode.removeChild(l.item(i))
}
}
}
}
}

View File

@ -1,14 +0,0 @@
dependencies {
implementation 'org.slf4j:slf4j-api:2.0.0'
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'io.gitlab.jfronny'
artifactId = 'commons-slf4j'
from components.java
}
}
}

View File

@ -0,0 +1,22 @@
plugins {
id("commons.library")
}
dependencies {
implementation("org.slf4j:slf4j-api:2.0.3")
implementation(project(":"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "io.gitlab.jfronny"
artifactId = "commons-slf4j"
from(components["java"])
}
}
}

View File

@ -1,13 +0,0 @@
dependencies {
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'io.gitlab.jfronny'
artifactId = 'muscript'
from components.java
}
}
}

21
muscript/build.gradle.kts Normal file
View File

@ -0,0 +1,21 @@
plugins {
id("commons.library")
}
dependencies {
implementation(project(":"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "io.gitlab.jfronny"
artifactId = "muscript"
from(components["java"])
}
}
}

View File

@ -1,6 +0,0 @@
rootProject.name = 'Commons'
include 'commons-gson'
include 'commons-slf4j'
include 'muscript'

5
settings.gradle.kts Normal file
View File

@ -0,0 +1,5 @@
rootProject.name = "Commons"
include("commons-gson")
include("commons-slf4j")
include("muscript")