Skip to content

Commit

Permalink
Update project structure to support multiple published subprojects
Browse files Browse the repository at this point in the history
- Add tiny-remapper-provider
- Update LICENSE year
- Update README to the new docs root URL
- Create conventions included build to separate logic
- Use (configuration) cache
- Restructure mappings-util -> lib, with proper root project
- Use typesafe project accessors
  • Loading branch information
770grappenmaker committed Jul 31, 2024
1 parent aa63d42 commit 240fb1a
Show file tree
Hide file tree
Showing 938 changed files with 82,448 additions and 11,352 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2023 NotEvenJoking/770grappenmaker
Copyright 2024 NotEvenJoking/770grappenmaker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
```

### Docs
Available in [GitHub Pages](https://770grappenmaker.github.io/mappings-util/).
Available in [GitHub Pages](https://770grappenmaker.github.io/mappings-util/mappings-util/).

### Examples
Note: these examples are in Kotlin, but can be applied in Java as well.
Expand Down
142 changes: 12 additions & 130 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,144 +1,26 @@
import org.jetbrains.dokka.gradle.DokkaTask
import java.net.URI
allprojects {
group = "com.grappenmaker"
version = "0.1.8"
}

plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.dokka)
`maven-publish`
`java-library`
signing
}

repositories {
mavenCentral()
}

group = "com.grappenmaker"
version = "0.1.7"

kotlin {
jvmToolchain(8)
explicitApi()
compilerOptions { freeCompilerArgs.add("-Xcontext-receivers") }
}

val dokkaJavadoc by tasks.getting(DokkaTask::class)
val dokkaAsJavadoc by tasks.registering(Jar::class) {
dependsOn(dokkaJavadoc)
from(dokkaJavadoc.outputDirectory)
archiveClassifier.set("javadoc")
}

java {
withSourcesJar()
}

dependencies {
api(libs.bundles.asm)
api(libs.coroutines.core)
testImplementation(kotlin("test"))
}

publishing {
publications {
fun MavenPublication.setup() {
artifact(dokkaAsJavadoc)
from(components["java"])
pom {
name = project.name
description = "A library for handling and using JVM name mappings (SRG, Tiny, Proguard)"
url = "https://github.com/770grappenmaker/mappings-util"
packaging = "jar"

licenses {
license {
name = "The MIT License"
url = "https://opensource.org/license/mit/"
distribution = "repo"
}
}

developers {
developer {
id = "770grappenmaker"
name = "NotEvenJoking"
email = "770grappenmaker@gmail.com"
url = "https://github.com/770grappenmaker/"
}
}

scm {
connection = "scm:git:git://github.com/770grappenmaker/mappings-util.git"
developerConnection = "scm:git:ssh://github.com:770grappenmaker/mappings-util.git"
url = "https://github.com/770grappenmaker/mappings-util/tree/main"
}
}
}

create<MavenPublication>("central") {
groupId = "io.github.770grappenmaker"
setup()
}

create<MavenPublication>("packages", MavenPublication::setup)
}

repositories {
maven {
name = "Packages"
url = uri("https://maven.pkg.github.com/770grappenmaker/mappings-util")

credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}

maven {
name = "Central"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials(PasswordCredentials::class)
}
}
}

signing {
sign(publishing.publications)
}

tasks {
test {
useJUnitPlatform()
testLogging {
events("passed")
}
}

withType<DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
val test by project(":samples").sourceSets.getting
samples.from(test.kotlin)
reportUndocumented = true

sourceLink {
localDirectory = rootDir
remoteUrl = URI("https://github.com/770grappenmaker/mappings-util/tree/main").toURL()
remoteLineSuffix = "#L"
}

includes.from("dokka-module.md")
val docsDir = projectDir.resolve("docs")
val deployDocs by registering(Copy::class) {
notCompatibleWithConfigurationCache("indirectly invokes dokka which makes it unsupported")

externalDocumentationLink {
url = URI("https://asm.ow2.io/javadoc/").toURL()
packageListUrl = project.layout.projectDirectory.file("asm.package-list").asFile.toURI().toURL()
}
}
}
dependsOn(dokkaHtmlMultiModule)
from(dokkaHtmlMultiModule.map { it.outputDirectory })
into(docsDir)

val dokkaHtml by getting
val deployDocs by registering(Copy::class) {
dependsOn(dokkaHtml)
from(dokkaHtml)
into(projectDir.resolve("docs"))
duplicatesStrategy = DuplicatesStrategy.FAIL
}
}
12 changes: 12 additions & 0 deletions conventions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}

dependencies {
implementation(libs.dokka)
implementation(libs.kotlin.jvm)
}
13 changes: 13 additions & 0 deletions conventions/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "conventions"

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
12 changes: 12 additions & 0 deletions conventions/src/main/kotlin/kotlin-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
id("org.jetbrains.kotlin.jvm")
}

repositories {
mavenCentral()
}

kotlin {
jvmToolchain(8)
compilerOptions { freeCompilerArgs.add("-Xcontext-receivers") }
}
126 changes: 126 additions & 0 deletions conventions/src/main/kotlin/published-library.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import java.net.URI

plugins {
`maven-publish`
`java-library`
signing
id("kotlin-convention")
id("org.jetbrains.dokka")
}

repositories {
mavenCentral()
}

val dokkaJavadoc by tasks.getting(DokkaTask::class)
val dokkaAsJavadoc by tasks.registering(Jar::class) {
dependsOn(dokkaJavadoc)
from(dokkaJavadoc.outputDirectory)
archiveClassifier.set("javadoc")
}

java { withSourcesJar() }
kotlin { explicitApi() }

interface PublishingConventionExtension {
val enablePackages: Property<Boolean>
}

val libraryExtension = project.extensions.create<PublishingConventionExtension>("publishedLibrary").apply {
enablePackages.convention(false)
}

afterEvaluate {
publishing {
publications {
fun MavenPublication.setup() {
artifact(dokkaAsJavadoc)
from(components["java"])

pom {
name = project.name
description = "A library for handling and using JVM name mappings (SRG, Tiny, Proguard)"
url = "https://github.com/770grappenmaker/mappings-util"
packaging = "jar"

licenses {
license {
name = "The MIT License"
url = "https://opensource.org/license/mit/"
distribution = "repo"
}
}

developers {
developer {
id = "770grappenmaker"
name = "NotEvenJoking"
email = "770grappenmaker@gmail.com"
url = "https://github.com/770grappenmaker/"
}
}

scm {
connection = "scm:git:git://github.com/770grappenmaker/mappings-util.git"
developerConnection = "scm:git:ssh://github.com:770grappenmaker/mappings-util.git"
url = "https://github.com/770grappenmaker/mappings-util/tree/main"
}
}
}

create<MavenPublication>("central") {
groupId = "io.github.770grappenmaker"
setup()
}

if (libraryExtension.enablePackages.get()) create<MavenPublication>("packages", MavenPublication::setup)
}

repositories {
if (libraryExtension.enablePackages.get()) maven {
name = "Packages"
url = uri("https://maven.pkg.github.com/770grappenmaker/mappings-util")

credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}

maven {
name = "Central"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials(PasswordCredentials::class)
}
}
}
}

signing {
sign(publishing.publications)
}

tasks {
withType<DokkaTaskPartial>().configureEach {
dokkaSourceSets.configureEach {
val test by project(":samples").sourceSets.getting
samples.from(test.extensions.getByName("kotlin"))
reportUndocumented = true

sourceLink {
localDirectory = rootDir
remoteUrl = URI("https://github.com/770grappenmaker/mappings-util/tree/main").toURL()
remoteLineSuffix = "#L"
}

includes.from("dokka-module.md")

externalDocumentationLink {
url = URI("https://asm.ow2.io/javadoc/").toURL()
packageListUrl = rootProject.layout.projectDirectory.file("asm.package-list").asFile.toURI().toURL()
}
}
}
}
Loading

0 comments on commit 240fb1a

Please sign in to comment.