Skip to content

Commit

Permalink
修改发布仓库为 Gradle Plugin Portal 并修改代码包名 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenRenJie authored Oct 9, 2022
1 parent 5f98fc5 commit 24f42a0
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 143 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/main.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
push:
tags:
- v*.*.*

jobs:
pushlish:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11

- name: Get version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}

- name: Publish
run: chmod +x ./gradlew && ./gradlew :plugin:publishPlugins -Pgradle.publish.version=$GRADLE_PUBLISH_VERSION -Pgradle.publish.key=$GRADLE_PUBLISH_KEY -Pgradle.publish.secret=$GRADLE_PUBLISH_SECRET
env:
GRADLE_PUBLISH_VERSION: ${{steps.get_version.outputs.VERSION}}
GRADLE_PUBLISH_KEY: ${{secrets.GRADLE_PUBLISH_KEY}}
GRADLE_PUBLISH_SECRET: ${{secrets.GRADLE_PUBLISH_SECRET}}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GDR(Gradle Dependencies Reportor)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.chrnie.gdr/plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.chrnie.gdr/plugin)
[![](https://img.shields.io/gradle-plugin-portal/v/io.github.knownitwhy.gdr)](https://plugins.gradle.org/plugin/io.github.knownitwhy.gdr)

Gradle 图形化依赖关系导出工具,支持导出:
1. 项目依赖关系图
Expand Down Expand Up @@ -28,7 +28,7 @@ Gradle 图形化依赖关系导出工具,支持导出:
2. 在需要导出依赖图的项目中应用插件:
``` groovy
plugins {
id("com.chrnie.gdr")
id("io.github.knownitwhy.gdr")
}
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {

dependencies {
classpath("com.android.tools.build:gradle:3.4.0")
classpath("com.chrnie.gdr:plugin")
classpath("io.github.knownitwhy:plugin")
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
90 changes: 17 additions & 73 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
plugins {
id("java-gradle-plugin")
id("org.jetbrains.kotlin.jvm") version "1.4.30"
id("maven-publish")
id("signing")
id("com.gradle.plugin-publish") version "1.0.0"
id("org.jetbrains.kotlin.jvm") version "1.7.0"
}

group = "io.github.knownitwhy"
version = findProperty("gradle.publish.version") as String? ?: "snapshot"

pluginBundle {
website = "https://github.com/knownitwhy/gdr"
vcsUrl = "https://github.com/knownitwhy/gdr.git"
tags = listOf("dependency","dependencies")
}

gradlePlugin {
val main by plugins.creating {
id = "com.chrnie.gdr"
implementationClass = "com.chrnie.gdr.GdrPlugin"
plugins.create("gdr") {
id = "io.github.knownitwhy.gdr"
implementationClass = "io.github.knownitwhy.gdr.GdrPlugin"
displayName = "Plugin for report dependencies of project, task, configuration"
description = "A plugin that helps you analyze dependencies of project, task, configuration"
}
}

Expand All @@ -18,70 +27,5 @@ repositories {
}

dependencies {
implementation("com.android.tools.build:gradle:3.4.0")
}

tasks.create("javadocJar", Jar::class.java) {
archiveClassifier.set("javadoc")
from("javadoc")
}

tasks.create("sourcesJar", Jar::class.java) {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}

publishing {
publications {
repositories {
maven {
name = "ossrh"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}

create<MavenPublication>("main") {
groupId = "com.chrnie.gdr"
artifactId = "plugin"
version = System.getenv("VERSION")?:"0.0.2"

from(components["java"])
artifact(tasks["javadocJar"])
artifact(tasks["sourcesJar"])

pom {
name.set("gdr")
description.set("Gradle 图形化依赖关系导出工具")
url.set("https://github.com/renjie-c/gdr")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

scm {
url.set("https://github.com/renjie-c/gdr")
}

developers {
developer {
id.set("chrnie")
name.set("ChenRenJie")
email.set("[email protected]")
}
}
}
}
}
}

signing {
useInMemoryPgpKeys(System.getenv("SIGNING_KEY"), System.getenv("SIGNING_PASSWORD"))
sign(publishing.publications["main"])
implementation("com.android.tools.build:gradle:4.0.2")
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.chrnie.gdr
package io.github.knownitwhy.gdr

import com.android.build.gradle.AppExtension
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.LibraryPlugin
import com.android.build.gradle.api.BaseVariant
import com.chrnie.gdr.ext.getTaskName
import com.chrnie.gdr.task.ReportConfigurationDependencies
import com.chrnie.gdr.task.ReportProjectDependencies
import com.chrnie.gdr.task.ReportTaskDependencies
import io.github.knownitwhy.gdr.ext.getTaskName
import io.github.knownitwhy.gdr.task.ReportConfigurationDependencies
import io.github.knownitwhy.gdr.task.ReportProjectDependencies
import io.github.knownitwhy.gdr.task.ReportTaskDependencies
import org.gradle.api.DomainObjectSet
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.SourceSetContainer

class GdrPlugin : Plugin<Project> {

companion object{
private const val TASK_GROUP = "help"
}
Expand Down Expand Up @@ -49,7 +49,7 @@ class GdrPlugin : Plugin<Project> {
it.outputDir = project.buildDir.resolve("reports/taskDependencies")
it.outputs.upToDateWhen { false }
}

project.tasks.create(
"reportConfigurationDependencies" ,
ReportConfigurationDependencies::class.java
Expand Down Expand Up @@ -86,4 +86,4 @@ class GdrPlugin : Plugin<Project> {
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.chrnie.gdr.dot
package io.github.knownitwhy.gdr.dot

fun buildDot(block: DotScope.() -> Unit): String {
val stmtList = mutableListOf<Stmt>()
Expand Down Expand Up @@ -66,7 +66,7 @@ enum class Shape(override val value: String) : Attribute {
override val key: String = "shape"
}

class Label(override val value: String): Attribute{
class Label(override val value: String): Attribute {

override val key: String = "label"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.chrnie.gdr.dot
package io.github.knownitwhy.gdr.dot

import org.gradle.api.Project
import java.io.ByteArrayInputStream
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.chrnie.gdr.ext
package io.github.knownitwhy.gdr.ext

import com.android.build.gradle.api.BaseVariant
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.chrnie.gdr.task
package io.github.knownitwhy.gdr.task

import com.chrnie.gdr.dot.DotScope
import com.chrnie.gdr.dot.Graphviz
import com.chrnie.gdr.dot.Shape
import com.chrnie.gdr.dot.buildDot
import io.github.knownitwhy.gdr.dot.DotScope
import io.github.knownitwhy.gdr.dot.Graphviz
import io.github.knownitwhy.gdr.dot.Shape
import io.github.knownitwhy.gdr.dot.buildDot
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
Expand All @@ -14,16 +15,18 @@ import java.io.File

abstract class ReportConfigurationDependencies : DefaultTask() {

@get:Input
@Option(
option = "configuration",
description = "指定要输出依赖关系的配置名,如果不设置则输出当前项目下所有配置的依赖关系"
)
var configurationName: String? = null

@get:Input
@Option(option = "verbose", description = "输出附加信息")
var verbose: Boolean = false

@OutputDirectory
@get:OutputDirectory
lateinit var outputDir: File

@get:OutputFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.chrnie.gdr.task
package io.github.knownitwhy.gdr.task

import com.chrnie.gdr.dot.DotScope
import com.chrnie.gdr.dot.Graphviz
import com.chrnie.gdr.dot.Shape
import com.chrnie.gdr.dot.buildDot
import io.github.knownitwhy.gdr.dot.DotScope
import io.github.knownitwhy.gdr.dot.Graphviz
import io.github.knownitwhy.gdr.dot.Shape
import io.github.knownitwhy.gdr.dot.buildDot
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
import org.gradle.api.artifacts.component.ProjectComponentIdentifier
Expand All @@ -18,16 +18,17 @@ import java.io.File

abstract class ReportProjectDependencies : DefaultTask() {

@Input
@get:Input
lateinit var variantName: String

@Input
@get:Input
lateinit var configurationName: String

@get:Input
@Option(option = "type", description = "指定要输出依赖的类型,可选值:all、project、external,默认值:all")
var typeName: String = Type.All.value

@OutputDirectory
@get:OutputDirectory
lateinit var outputDir: File

@get:OutputFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.chrnie.gdr.task
package io.github.knownitwhy.gdr.task

import com.chrnie.gdr.dot.DotScope
import com.chrnie.gdr.dot.Graphviz
import com.chrnie.gdr.dot.Shape
import com.chrnie.gdr.dot.buildDot
import io.github.knownitwhy.gdr.dot.DotScope
import io.github.knownitwhy.gdr.dot.Graphviz
import io.github.knownitwhy.gdr.dot.Shape
import io.github.knownitwhy.gdr.dot.buildDot
import org.gradle.api.DefaultTask
import org.gradle.api.Task
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
Expand All @@ -14,16 +15,19 @@ import java.io.File

abstract class ReportTaskDependencies : DefaultTask() {

@get:Input
@Option(option = "task", description = "指定要输出依赖关系的任务名,如果不设置则输出当前项目下所有任务的依赖关系")
var taskName: String? = null

@get:Input
@Option(option = "includeDependentProject", description = "是否包含依赖项目的任务")
var includeDependentProject: Boolean = false

@get:Input
@Option(option = "verbose", description = "输出附加信息")
var verbose: Boolean = false

@OutputDirectory
@get:OutputDirectory
lateinit var outputDir: File

@get:OutputFile
Expand Down
2 changes: 1 addition & 1 deletion sample/android-application/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("com.android.application")
id("com.chrnie.gdr")
id("io.github.knownitwhy.gdr")
}

android {
Expand Down
2 changes: 1 addition & 1 deletion sample/android-library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("com.android.library")
id("com.chrnie.gdr")
id("io.github.knownitwhy.gdr")
}

android {
Expand Down
Loading

0 comments on commit 24f42a0

Please sign in to comment.