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:
Родитель
7681e25634
Коммит
0623203e99
|
@ -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 {
|
||||
|
|
Загрузка…
Ссылка в новой задаче