Skip to content

Commit

Permalink
Restructure convention plugins
Browse files Browse the repository at this point in the history
Fixes a bug where all templates where being published under the wrong group
  • Loading branch information
ajoberstar committed Jan 9, 2021
1 parent cfa61e7 commit 2239f51
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 107 deletions.
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
plugins {
id("convention.lint")

id("org.ajoberstar.grgit")
id("org.ajoberstar.reckon")
id("com.diffplug.spotless")
}

reckon {
Expand Down
50 changes: 50 additions & 0 deletions buildSrc/src/main/kotlin/convention.clojars-publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
plugins {
java
`maven-publish`
}

java {
withSourcesJar()
}

publishing {
repositories {
maven {
name = "clojars"
url = uri("https://repo.clojars.org")
credentials {
username = System.getenv("CLOJARS_USER")
password = System.getenv("CLOJARS_TOKEN")
}
}
}

publications.withType<MavenPublication>() {
// use static versions in poms
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}

pom {
// include repository info in POM (needed for cljdoc)
scm {
connection.set("https://github.com/clojurephant/clojurephant.git")
developerConnection.set("git@github.com:clojurephant/clojurephant.git")
url.set("https://github.com/clojurephant/clojurephant")
if (!version.toString().contains("+")) {
tag.set(version.toString())
}
}
}
}
}

// Clojars doesn"t support module metadata
tasks.withType<GenerateModuleMetadata>() {
enabled = false
}
11 changes: 11 additions & 0 deletions buildSrc/src/main/kotlin/convention.lint.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
id("com.diffplug.spotless")
}

spotless {
java {
importOrder("java", "javax", "")
removeUnusedImports()
eclipse().configFile(rootProject.file("gradle/eclipse-java-formatter.xml"))
}
}
87 changes: 0 additions & 87 deletions buildSrc/src/main/kotlin/library-convention.gradle.kts

This file was deleted.

23 changes: 12 additions & 11 deletions clojurephant-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ import dev.clojurephant.plugin.clojure.tasks.ClojureCompile
import org.gradle.plugins.ide.eclipse.model.EclipseModel

plugins {
`library-convention`
`java-gradle-plugin`
id("convention.clojars-publish")
id("convention.lint")

id("org.ajoberstar.stutter")
id("dev.clojurephant.clojure")

`java-gradle-plugin`
id("com.gradle.plugin-publish")
id("org.ajoberstar.stutter")
}

group = "dev.clojurephant"

configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
Expand Down Expand Up @@ -67,14 +76,6 @@ tasks.withType<Test>().matching { t -> t.name.startsWith("compatTest") }.all {
systemProperty("org.gradle.testkit.dir", file("build/stutter-test-kit").absolutePath)
}

publishing {
publications {
create<MavenPublication>("pluginMaven") {
artifact(tasks.sourcesJar)
}
}
}

gradlePlugin {
plugins {
create("clojureBase") {
Expand Down
12 changes: 10 additions & 2 deletions clojurephant-tools/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import dev.clojurephant.plugin.clojure.tasks.ClojureCheck
import dev.clojurephant.plugin.clojure.tasks.ClojureCompile

plugins {
`library-convention`
id("convention.clojars-publish")
id("convention.lint")

id("dev.clojurephant.clojure")
}

group = "dev.clojurephant"

configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
Expand All @@ -18,7 +27,6 @@ publishing {
publications {
create<MavenPublication>("main") {
from(components["java"])
artifact(tasks.sourcesJar)
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ pluginManagement {
}
}

dependencyResolutionManagement {
repositories {
mavenCentral()
maven {
name = "Clojars"
url = uri("https://repo.clojars.org/")
}
}
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
}

rootProject.name = "clojurephant"
include("clojurephant-plugin")
include("clojurephant-tools")
Expand Down
5 changes: 3 additions & 2 deletions templates/clojurephant-clj-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
`clj-new-template`
`library-convention`
id("convention.clojars-publish")
id("convention.lint")
id("convention.template")
}
5 changes: 3 additions & 2 deletions templates/clojurephant-clj-lib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
`clj-new-template`
`library-convention`
id("convention.clojars-publish")
id("convention.lint")
id("convention.template")
}
5 changes: 3 additions & 2 deletions templates/clojurephant-cljs-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
`clj-new-template`
`library-convention`
id("convention.clojars-publish")
id("convention.lint")
id("convention.template")
}

0 comments on commit 2239f51

Please sign in to comment.