Skip to content

Commit

Permalink
working on the base plugin. (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek authored Aug 22, 2024
1 parent 402b46f commit 65fe6b0
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 67 deletions.
8 changes: 8 additions & 0 deletions base/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import net.infumia.gradle.configureKotlin
import net.infumia.gradle.configurePublish

plugins { `kotlin-dsl` }

configureKotlin()

configurePublish()
9 changes: 9 additions & 0 deletions base/src/main/kotlin/TemplatorBasePlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.infumia.templator

import org.gradle.api.Plugin
import org.gradle.api.Project

class TemplatorBasePlugin : Plugin<Project> {

override fun apply(target: Project) {}
}
8 changes: 2 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import net.infumia.gradle.spotless
import net.infumia.gradle.configureSpotless

plugins { kotlin("jvm") }

repositories { mavenCentral() }

spotless()
configureSpotless()
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plugins { `kotlin-dsl` }
plugins { alias(libs.plugins.kotlin.dsl) }

repositories {
mavenCentral()
Expand Down
43 changes: 0 additions & 43 deletions buildSrc/src/main/kotlin/net/infumia/gradle/common.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,53 @@ package net.infumia.gradle
import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension

fun Project.spotless() {
fun Project.configureKotlin(
javaVersion: Int = 8,
sources: Boolean = true,
javadoc: Boolean = true
) {
apply<DokkaPlugin>()
apply(plugin = "org.jetbrains.kotlin.jvm")

repositories.mavenCentral()

extensions.configure<KotlinJvmProjectExtension> { jvmToolchain(javaVersion) }

if (javadoc) {
val javadocJar by
tasks.creating(Jar::class) {
dependsOn("javadoc")
archiveClassifier.set("javadoc")
from(javadoc)
}
}

if (sources) {
val sourceSets = extensions.getByType<JavaPluginExtension>().sourceSets
val sourcesJar by
tasks.creating(Jar::class) {
dependsOn("classes")
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
}
}

// TODO: portlek, Implement the publishing to gradle portal.
fun Project.configurePublish(
// moduleName: String? = null
) {
// val projectName = "templator${if (moduleName == null) "" else "-$moduleName"}"
// val signRequired = project.hasProperty("sign-required")
}

fun Project.configureSpotless() {
val subProjects = subprojects.map { it.projectDir.toRelativeString(projectDir) }

repositories.mavenCentral()
Expand Down
16 changes: 0 additions & 16 deletions buildSrc/src/main/kotlin/net/infumia/gradle/publish.kt

This file was deleted.

3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ kotlin = "2.0.0"
kotlin-plugin = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" }
dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version = "1.9.20" }
spotless-plugin = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.25.0" }

[plugins]
kotlin-dsl = { id = "org.gradle.kotlin.kotlin-dsl", version = "5.1.0" }
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" }

rootProject.name = "templator"

include("base")

0 comments on commit 65fe6b0

Please sign in to comment.