Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [Modernize] Update project to use modern gradle practices #29

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 51 additions & 33 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,85 @@ import com.gradle.publish.PublishTask.GRADLE_PUBLISH_KEY
import com.gradle.publish.PublishTask.GRADLE_PUBLISH_SECRET

plugins {
id("groovy")
id("com.gradle.plugin-publish") version "1.2.0"
id("java-gradle-plugin")
id("groovy")
id("org.jetbrains.kotlin.jvm") version "1.8.20"
id("io.gitlab.arturbosch.detekt") version "1.22.0"
id("com.gradle.plugin-publish") version "1.2.0"
id("java-gradle-plugin")
}

val setupPluginUpload by tasks.registering {
// TODO switch this to use github action
if ("CI" in System.getenv() && "TRAVIS" in System.getenv()) {
// Used for publishing from Travis
// TODO switch this to use github action
if ("CI" in System.getenv() && "TRAVIS" in System.getenv()) {
// Used for publishing from Travis

val key = System.getenv(GRADLE_PUBLISH_KEY) ?: System.getProperty(GRADLE_PUBLISH_KEY)
val secret = System.getenv(GRADLE_PUBLISH_SECRET) ?: System.getProperty(GRADLE_PUBLISH_SECRET)
val key = System.getenv(GRADLE_PUBLISH_KEY) ?: System.getProperty(GRADLE_PUBLISH_KEY)
val secret = System.getenv(GRADLE_PUBLISH_SECRET) ?: System.getProperty(GRADLE_PUBLISH_SECRET)

if (key == null || secret == null) {
error("GRADLE_PUBLISH_KEY and/or GRADLE_PUBLISH_SECRET are not defined environment variables")
}

System.setProperty(GRADLE_PUBLISH_KEY, key)
System.setProperty(GRADLE_PUBLISH_SECRET, secret)
if (key == null || secret == null) {
error("GRADLE_PUBLISH_KEY and/or GRADLE_PUBLISH_SECRET are not defined environment variables")
}

System.setProperty(GRADLE_PUBLISH_KEY, key)
System.setProperty(GRADLE_PUBLISH_SECRET, secret)
}
}

tasks.named("publishPlugins") {
dependsOn(setupPluginUpload)
dependsOn(setupPluginUpload)
}

group = "org.assertj"
version = "2.2.0-SNAPSHOT"

gradlePlugin {
website.set("https://github.com/assertj/assertj-generator-gradle-plugin")
vcsUrl.set("https://github.com/assertj/assertj-generator-gradle-plugin.git")
website.set("https://github.com/assertj/assertj-generator-gradle-plugin")
vcsUrl.set("https://github.com/assertj/assertj-generator-gradle-plugin.git")

plugins {
create("assertJGeneratorPlugin") {
id = "org.assertj.generator"
plugins {
create("assertJGeneratorPlugin") {
id = "org.assertj.generator"

displayName = "AssertJ Generator Gradle Plugin"
description = "Run the AssertJ generator against your source files to generate test sources."
displayName = "AssertJ Generator Gradle Plugin"
description = "Run the AssertJ generator against your source files to generate test sources."

tags.set(listOf("assertj", "testing", "generator"))
tags.set(listOf("assertj", "testing", "generator"))

implementationClass = "org.assertj.generator.gradle.AssertJGeneratorGradlePlugin"
}
implementationClass = "org.assertj.generator.gradle.AssertJGeneratorGradlePlugin"
}
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
api(gradleApi())
api(localGroovy())
api(gradleApi())

api("org.assertj:assertj-core:3.24.2")
api("org.assertj:assertj-assertions-generator:2.2.1")

implementation(gradleKotlinDsl())
implementation("com.google.guava:guava:31.1-jre")

testCompileOnly("org.jetbrains:annotations:24.0.1")

api("org.assertj:assertj-core:3.24.2")
api("org.assertj:assertj-assertions-generator:2.2.1")
testImplementation(gradleTestKit())
testImplementation("junit:junit:4.13.2")
}

detekt {
parallel = true
autoCorrect = true

implementation("com.google.guava:guava:31.1-jre")
buildUponDefaultConfig = true // preconfigure defaults
config = files("$rootDir/config/detekt-config.yml")

testImplementation(gradleTestKit())
testImplementation("junit:junit:4.13.2")
allRules = false // activate all available (even unstable) rules.
}

dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0")
}

20 changes: 20 additions & 0 deletions config/detekt-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
formatting:
active: true
Indentation:
active: true
indentSize: 2
PackageName:
active: false

style:
active: true
ReturnCount:
max: 4

complexity:
LongMethod:
excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ]

naming:
PackageNaming:
packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9_]*)*'

This file was deleted.

Loading