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

Use gradle maven publish plugin #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
git config --local user.name "GitHub Action"
owner=$(echo $GITHUB_REPOSITORY | cut -d/ -f1 | tr '[:upper:]' '[:lower:]')
name=$(echo $GITHUB_REPOSITORY | cut -d/ -f2 | tr '[:upper:]' '[:lower:]' | tr -d "-" | tr -d ".")
./change_package_name.sh com.github.${owner,,}.${name,,} "$(echo $GITHUB_REPOSITORY | cut -d/ -f2)"
./change_package_name.sh $GITHUB_REPOSITORY
# Push changes
- name: Push changes
uses: ad-m/github-push-action@v0.6.0
Expand Down
18 changes: 7 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
plugins {
kotlin("jvm") version "1.8.20"
`maven-publish`
}

group = "org.example.detekt"
version = "1.0-SNAPSHOT"
buildscript {
dependencies {
classpath("com.vanniktech:gradle-maven-publish-plugin:0.21.0")
}
}

apply(plugin="com.vanniktech.maven.publish")

dependencies {
compileOnly("io.gitlab.arturbosch.detekt:detekt-api:1.22.0")
Expand All @@ -23,11 +27,3 @@ tasks.withType<Test>().configureEach {
systemProperty("junit.jupiter.testinstance.lifecycle.default", "per_class")
systemProperty("compile-snippet-tests", project.hasProperty("compile-test-snippets"))
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
}
15 changes: 10 additions & 5 deletions change_package_name.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/usr/bin/env bash

package_name=$1
github_repository=$1
owner=$(echo $github_repository | cut -d/ -f1 | tr '[:upper:]' '[:lower:]')
name=$(echo $github_repository | cut -d/ -f2 | tr '[:upper:]' '[:lower:]' | tr -d "-" | tr -d ".")
package_name="com.github.${owner}.${name}"
directory=$(echo $package_name | tr "." "/")
repo_name=$2
repo_name=$(echo $github_repository | cut -d/ -f2)

mkdir -p src/main/kotlin/$directory
mkdir -p src/test/kotlin/$directory

find src/main src/test -type f -exec sed -i s/org.example.detekt/$package_name/g {} +
sed -i s/org.example.detekt/$package_name/g build.gradle.kts
sed -i s/detekt-custom-rule/$repo_name/g settings.gradle.kts
find src/main src/test -type f -exec sed -i "s/org.example.detekt/$package_name/g" {} +

sed -i "s/org.example.detekt/com.github.${owner}/g" build.gradle.kts gradle.properties
sed -i "s/detekt-custom-rule/$repo_name/g" settings.gradle.kts gradle.properties
sed -i "s|github.com/example/custom-rule|github.com/$github_repository|g" gradle.properties

mv src/main/kotlin/org/example/detekt/* src/main/kotlin/$directory
mv src/test/kotlin/org/example/detekt/* src/test/kotlin/$directory
Expand Down
21 changes: 20 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
kotlin.code.style=official
GROUP=org.example.detekt
POM_ARTIFACT_ID=detekt-custom-rule
VERSION_NAME=0.0.1

POM_NAME=detekt-custom-rule
POM_DESCRIPTION=A description for my RuleSet.
POM_INCEPTION_YEAR=2022
POM_URL=https://github.com/example/custom-rule/

POM_LICENSE_NAME=
POM_LICENSE_URL=
POM_LICENSE_DIST=repo

POM_SCM_URL=https://github.com/example/custom-rule/
POM_SCM_CONNECTION=scm:git:git://github.com/example/custom-rule.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/example/custom-rule.git

POM_DEVELOPER_ID=username
POM_DEVELOPER_NAME=User Name
POM_DEVELOPER_URL=https://github.com/username/