mirror of
https://github.com/fankes/unmeta-gradle-plugin.git
synced 2025-09-04 01:55:16 +08:00
Rebrand to unmeta-gradle-plugin
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
ID=com.ncorti.kotlin.gradle.template.plugin
|
||||
ID=com.axzae.unmeta
|
||||
VERSION=1.0.0
|
||||
GROUP=com.ncorti.kotlin.gradle.template
|
||||
DISPLAY_NAME=An empty Gradle Plugin from a template
|
||||
DESCRIPTION=An empty Gradle plugin created from a template
|
||||
WEBSITE=https://github.com/cortinico/kotlin-gradle-plugin-template
|
||||
VCS_URL=https://github.com/cortinico/kotlin-gradle-plugin-template
|
||||
IMPLEMENTATION_CLASS=com.ncorti.kotlin.gradle.template.plugin.TemplatePlugin
|
||||
GROUP=com.axzae
|
||||
DISPLAY_NAME=Unmeta Kotlin Gradle Plugin for Android
|
||||
DESCRIPTION=Remove @DebugMetadata annotation from your Kotlin classes
|
||||
WEBSITE=https://github.com/axzae/unmeta-gradle-plugin
|
||||
VCS_URL=https://github.com/axzae/unmeta-gradle-plugin
|
||||
IMPLEMENTATION_CLASS=com.axzae.unmeta.UnmetaPlugin
|
||||
|
@@ -32,7 +32,7 @@ gradlePlugin {
|
||||
version = property("VERSION").toString()
|
||||
description = property("DESCRIPTION").toString()
|
||||
displayName = property("DISPLAY_NAME").toString()
|
||||
tags.set(listOf("plugin", "gradle", "sample", "template"))
|
||||
tags.set(listOf("kotlin", "metadata"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.ncorti.kotlin.gradle.template.plugin
|
||||
package com.axzae.unmeta
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
@@ -8,7 +8,7 @@ import javax.inject.Inject
|
||||
const val DEFAULT_OUTPUT_FILE = "template-example.txt"
|
||||
|
||||
@Suppress("UnnecessaryAbstractClass")
|
||||
abstract class TemplateExtension @Inject constructor(project: Project) {
|
||||
abstract class UnmetaExtension @Inject constructor(project: Project) {
|
||||
|
||||
private val objects = project.objects
|
||||
|
||||
@@ -21,6 +21,6 @@ abstract class TemplateExtension @Inject constructor(project: Project) {
|
||||
|
||||
// Example of a property with a default set with .convention
|
||||
val outputFile: RegularFileProperty = objects.fileProperty().convention(
|
||||
project.layout.buildDirectory.file(DEFAULT_OUTPUT_FILE)
|
||||
project.layout.buildDirectory.file(DEFAULT_OUTPUT_FILE),
|
||||
)
|
||||
}
|
@@ -1,18 +1,18 @@
|
||||
package com.ncorti.kotlin.gradle.template.plugin
|
||||
package com.axzae.unmeta
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
const val EXTENSION_NAME = "templateExampleConfig"
|
||||
const val TASK_NAME = "templateExample"
|
||||
const val EXTENSION_NAME = "unmeta"
|
||||
const val TASK_NAME = "unmetaTask"
|
||||
|
||||
abstract class TemplatePlugin : Plugin<Project> {
|
||||
abstract class UnmetaPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
// Add the 'template' extension object
|
||||
val extension = project.extensions.create(EXTENSION_NAME, TemplateExtension::class.java, project)
|
||||
val extension = project.extensions.create(EXTENSION_NAME, UnmetaExtension::class.java, project)
|
||||
|
||||
// Add a task that uses configuration from the extension object
|
||||
project.tasks.register(TASK_NAME, TemplateExampleTask::class.java) {
|
||||
project.tasks.register(TASK_NAME, UnmetaTask::class.java) {
|
||||
it.tag.set(extension.tag)
|
||||
it.message.set(extension.message)
|
||||
it.outputFile.set(extension.outputFile)
|
@@ -1,7 +1,8 @@
|
||||
package com.ncorti.kotlin.gradle.template.plugin
|
||||
package com.axzae.unmeta
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.plugins.BasePlugin
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.Optional
|
||||
@@ -9,13 +10,11 @@ import org.gradle.api.tasks.OutputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.options.Option
|
||||
|
||||
abstract class TemplateExampleTask : DefaultTask() {
|
||||
abstract class UnmetaTask : DefaultTask() {
|
||||
|
||||
init {
|
||||
description = "Just a sample template task"
|
||||
|
||||
// Don't forget to set the group here.
|
||||
// group = BasePlugin.BUILD_GROUP
|
||||
description = "Drop Kotlin @DebugMetadata from java classes"
|
||||
group = BasePlugin.BUILD_GROUP
|
||||
}
|
||||
|
||||
@get:Input
|
||||
@@ -31,7 +30,7 @@ abstract class TemplateExampleTask : DefaultTask() {
|
||||
abstract val outputFile: RegularFileProperty
|
||||
|
||||
@TaskAction
|
||||
fun sampleAction() {
|
||||
fun unmetaAction() {
|
||||
val prettyTag = tag.orNull?.let { "[$it]" } ?: ""
|
||||
|
||||
logger.lifecycle("$prettyTag message is: ${message.orNull}")
|
@@ -1,4 +1,4 @@
|
||||
package com.ncorti.kotlin.gradle.template.plugin
|
||||
package com.axzae.unmeta
|
||||
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -6,36 +6,36 @@ import org.junit.Assert.assertNotNull
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class TemplatePluginTest {
|
||||
class UnmetaPluginTest {
|
||||
|
||||
@Test
|
||||
fun `plugin is applied correctly to the project`() {
|
||||
val project = ProjectBuilder.builder().build()
|
||||
project.pluginManager.apply("com.ncorti.kotlin.gradle.template.plugin")
|
||||
project.pluginManager.apply("com.axzae.unmeta")
|
||||
|
||||
assert(project.tasks.getByName("templateExample") is TemplateExampleTask)
|
||||
assert(project.tasks.getByName("unmetaTask") is UnmetaTask)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extension templateExampleConfig is created correctly`() {
|
||||
fun `extension unmeta is created correctly`() {
|
||||
val project = ProjectBuilder.builder().build()
|
||||
project.pluginManager.apply("com.ncorti.kotlin.gradle.template.plugin")
|
||||
project.pluginManager.apply("com.axzae.unmeta")
|
||||
|
||||
assertNotNull(project.extensions.getByName("templateExampleConfig"))
|
||||
assertNotNull(project.extensions.getByName("unmeta"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parameters are passed correctly from extension to task`() {
|
||||
val project = ProjectBuilder.builder().build()
|
||||
project.pluginManager.apply("com.ncorti.kotlin.gradle.template.plugin")
|
||||
project.pluginManager.apply("com.axzae.unmeta")
|
||||
val aFile = File(project.projectDir, ".tmp")
|
||||
(project.extensions.getByName("templateExampleConfig") as TemplateExtension).apply {
|
||||
(project.extensions.getByName("unmeta") as UnmetaExtension).apply {
|
||||
tag.set("a-sample-tag")
|
||||
message.set("just-a-message")
|
||||
outputFile.set(aFile)
|
||||
}
|
||||
|
||||
val task = project.tasks.getByName("templateExample") as TemplateExampleTask
|
||||
val task = project.tasks.getByName("unmetaTask") as UnmetaTask
|
||||
|
||||
assertEquals("a-sample-tag", task.tag.get())
|
||||
assertEquals("just-a-message", task.message.get())
|
@@ -31,6 +31,6 @@ gradleEnterprise {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = ("com.ncorti.kotlin.gradle.template")
|
||||
rootProject.name = ("com.axzae.unmeta")
|
||||
|
||||
include(":plugin")
|
||||
|
Reference in New Issue
Block a user