Move plugin ID strings to constants, stop declaring third-party plugins (#520)

* Move plugin ID strings to constants, stop declaring third-party plugins

* Maybe we need to apply jacoco after all?
This commit is contained in:
Ben Bader 2022-12-16 09:38:34 -08:00 коммит произвёл GitHub
Родитель 7681e25634
Коммит 0623203e99
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 58 добавлений и 23 удалений

Просмотреть файл

@ -1,6 +1,6 @@
plugins {
id 'java-gradle-plugin'
alias(libs.plugins.kotlin.jvm)
alias libs.plugins.kotlin.jvm
}
gradlePlugin {
@ -40,6 +40,7 @@ repositories {
}
dependencies {
implementation libs.dokka
implementation libs.kotlin.gradle.plugin
implementation libs.mavenPublishPlugin
}

Просмотреть файл

@ -0,0 +1,33 @@
/*
* Thrifty
*
* Copyright (c) Microsoft Corporation
*
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE,
* FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
*
* See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
*/
package com.microsoft.thrifty
object Plugins {
const val JAVA = "java-library"
const val IDEA = "idea"
const val JACOCO = "jacoco"
const val KOTLIN_JVM = "org.jetbrains.kotlin.jvm"
const val KOTLIN_MPP = "org.jetbrains.kotlin.multiplatform"
const val DOKKA = "org.jetbrains.dokka"
const val MAVEN_PUBLISH = "com.vanniktech.maven.publish"
}

Просмотреть файл

@ -20,9 +20,11 @@
*/
package com.microsoft.thrifty
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.plugins.ExtensionContainer
import org.gradle.api.plugins.PluginContainer
import org.gradle.api.tasks.TaskCollection
val Project.isReleaseBuild: Boolean
@ -36,3 +38,5 @@ inline fun <reified T : Task> TaskCollection<in Task>.withType(): TaskCollection
}
inline fun <reified T> ExtensionContainer.findByType(): T? = findByType(T::class.java)
inline fun <reified T : Plugin<Project>> PluginContainer.apply(): T = apply(T::class.java)

Просмотреть файл

@ -39,9 +39,9 @@ class ThriftyJavaPlugin : Plugin<Project> {
private fun applyBasePlugins(project: Project) {
with(project.plugins) {
apply("java-library")
apply("idea")
apply("jacoco")
apply(Plugins.JAVA)
apply(Plugins.IDEA)
apply(Plugins.JACOCO)
}
}
@ -51,7 +51,7 @@ class ThriftyJavaPlugin : Plugin<Project> {
}
private fun applyJavaSettings(project: Project) {
val java = project.extensions.findByType(JavaPluginExtension::class.java)!!
val java = project.extensions.findByType<JavaPluginExtension>()!!
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8
@ -64,7 +64,7 @@ class ThriftyJavaPlugin : Plugin<Project> {
}
private fun configureTestTasks(project: Project) {
project.tasks.withType(Test::class.java).configureEach { task ->
project.tasks.withType<Test>().configureEach { task ->
task.useJUnitPlatform()
task.testLogging { logging ->
logging.events(TestLogEvent.FAILED)

Просмотреть файл

@ -39,10 +39,10 @@ class ThriftyKotlinPlugin : Plugin<Project> {
}
private fun applyBasePlugins(project: Project) {
project.plugins.apply("thrifty-jvm-module")
project.plugins.apply("org.jetbrains.kotlin.jvm")
project.plugins.apply<ThriftyJavaPlugin>()
project.plugins.apply(Plugins.KOTLIN_JVM)
if (project.isReleaseBuild) {
project.plugins.apply("org.jetbrains.dokka")
project.plugins.apply(Plugins.DOKKA)
}
}

Просмотреть файл

@ -25,10 +25,10 @@ import org.gradle.api.Project
class ThriftyMppPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.plugins.apply("thrifty-jvm-module")
project.plugins.apply("org.jetbrains.kotlin.multiplatform")
project.plugins.apply<ThriftyJavaPlugin>()
project.plugins.apply(Plugins.KOTLIN_MPP)
if (project.isReleaseBuild) {
project.plugins.apply("org.jetbrains.dokka")
project.plugins.apply(Plugins.DOKKA)
}
}
}

Просмотреть файл

@ -27,10 +27,8 @@ import org.gradle.api.Project
@Suppress("UnstableApiUsage")
class ThriftyPublishPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.plugins.apply("com.vanniktech.maven.publish")
val ext = project
.extensions
.findByType<MavenPublishBaseExtension>()!!
project.plugins.apply(Plugins.MAVEN_PUBLISH)
val ext = project.extensions.findByType<MavenPublishBaseExtension>()!!
ext.publishToMavenCentral()
if (project.isReleaseBuild) {

Просмотреть файл

@ -20,10 +20,7 @@
*/
plugins {
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.kotlin.jvm) apply false
id 'thrifty-kotlin-module' apply false
id 'jacoco'
}

Просмотреть файл

@ -8,6 +8,7 @@ okio = "3.2.0"
antlr = "org.antlr:antlr4:4.9.1"
apacheThrift = "org.apache.thrift:libthrift:0.17.0"
clikt = "com.github.ajalt.clikt:clikt:3.1.0"
dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.7.20"
guava = "com.google.guava:guava:31.1-jre"
javaPoet = "com.squareup:javapoet:1.13.0"
kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }

Просмотреть файл

@ -22,7 +22,7 @@
plugins {
id 'thrifty-kotlin-module'
id 'thrifty-publish-module'
alias(libs.plugins.shadow)
alias libs.plugins.shadow
}
dependencies {

Просмотреть файл

@ -23,7 +23,8 @@ plugins {
id 'thrifty-jvm-module'
id 'thrifty-publish-module'
id 'java-gradle-plugin'
alias(libs.plugins.gradlePluginPublish)
alias libs.plugins.gradlePluginPublish
}
pluginBundle {

Просмотреть файл

@ -22,7 +22,7 @@
plugins {
id 'thrifty-kotlin-module'
id 'application'
alias(libs.plugins.shadow)
alias libs.plugins.shadow
}
dependencies {