Skip to content

Commit

Permalink
patch: fixed javadoc and sources generation
Browse files Browse the repository at this point in the history
* fixed javadoc and sources jar generation
* increased max meta memory space size
  • Loading branch information
Im-Fran committed Jan 19, 2024
1 parent e0fd964 commit ecb57df
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 27 deletions.
10 changes: 10 additions & 0 deletions build-info/build.gradle.kts
@@ -1,3 +1,5 @@
import org.jetbrains.dokka.gradle.DokkaTask

plugins {
id("net.kyori.blossom") version "2.1.0" // Placeholder injection
}
Expand All @@ -22,4 +24,12 @@ sourceSets {
}
}
}
}

tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets {
configureEach {
sourceRoots.from(file("src/"))
}
}
}
65 changes: 39 additions & 26 deletions build.gradle.kts
@@ -1,6 +1,6 @@

import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import java.util.*

plugins {
Expand All @@ -12,6 +12,15 @@ plugins {
id("org.jetbrains.dokka") version "1.9.10" // Dokka (Kotlin Docs)
}

/*
The project version can be:
- environment variable VERSION or the manually added version
- If the environment variable ENV is set to dev, the project
version will have appended the git commit short hash + SNAPSHOT
*/
val projectVersion = (env["VERSION"] ?: "1.0.0") + (if(env["ENV"] == "dev") "-${env["GIT_COMMIT_SHORT_HASH"] ?: UUID.randomUUID().toString().replace("-", "").split("").shuffled().joinToString("").substring(0,8)}-SNAPSHOT" else "")
println("This build version was '$projectVersion'")

allprojects {
apply {
plugin("com.github.johnrengelman.shadow")
Expand All @@ -20,14 +29,6 @@ allprojects {
plugin("org.jetbrains.dokka")
}

/*
The project version can be:
- environment variable VERSION or the manually added version
- If the environment variable ENV is set to dev, the project
version will have appended the git commit short hash + SNAPSHOT
*/
val projectVersion = (env["VERSION"] ?: "1.0.0") + (if(env["ENV"] == "dev") "-${env["GIT_COMMIT_SHORT_HASH"] ?: UUID.randomUUID().toString().replace("-", "").split("").shuffled().joinToString("").substring(0,8)}-SNAPSHOT" else "")

group = "xyz.theprogramsrc"
version = projectVersion.replaceFirst("v", "").replace("/", "")
description = "The best way to create a kotlin project."
Expand All @@ -48,16 +49,18 @@ allprojects {
}

subprojects {
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withSourcesJar()
withJavadocJar()
}
apply(plugin = "org.jetbrains.dokka")

tasks {
jar {
dependsOn(dokkaJavadoc)
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withSourcesJar()
withJavadocJar()
}

named<DokkaTaskPartial>("dokkaHtmlPartial") {
outputDirectory = layout.buildDirectory.dir("dokka")
}
}
}
Expand Down Expand Up @@ -108,15 +111,25 @@ tasks {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

dokkaHtml {
outputDirectory.set(layout.buildDirectory.dir("dokka/"))
register<Jar>("mergeSourcesJar") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier = "sources"
from(subprojects.filter { subproject -> subproject.tasks.any { task -> task.name == "sourcesJar" } }.flatMap { subproject -> subproject.sourceSets.map { sourceSet -> sourceSet.allSource } })

copy {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}

val dokkaJavadocJar by tasks.register<Jar>("dokkaJavadocJar") {
dependsOn(tasks.dokkaJavadoc, tasks.dokkaHtml)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
dokkaHtmlMultiModule {
outputDirectory = rootProject.layout.buildDirectory.dir("dokka/")
}

register<Jar>("dokkaJavadocJar") {
dependsOn(dokkaHtmlMultiModule)
from(dokkaHtmlMultiModule.flatMap { dokkaTask -> dokkaTask.outputDirectory })
archiveClassifier.set("javadoc")
}
}

publishing {
Expand Down Expand Up @@ -157,8 +170,8 @@ publishing {
artifactId = rootProject.name.lowercase()

component(this@create)
artifact(dokkaJavadocJar)
artifact(tasks.kotlinSourcesJar)
artifact(tasks.named("dokkaJavadocJar"))
artifact(tasks.named("mergeSourcesJar"))

pom {
name.set(rootProject.name)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
@@ -1 +1 @@
org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m
org.gradle.jvmargs=-XX:MaxMetaspaceSize=4096m
4 changes: 4 additions & 0 deletions simplecoreapi/build.gradle.kts
@@ -1,5 +1,9 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id("org.jetbrains.dokka")
}

dependencies {
/* Api */
compileOnly(project(":build-info"))
Expand Down

0 comments on commit ecb57df

Please sign in to comment.