Skip to content

Commit

Permalink
Merge pull request #2652 from square/bquenaudon.2023-09-18.internalpl…
Browse files Browse the repository at this point in the history
…ugin

Introduce internal plugin
  • Loading branch information
oldergod authored Oct 20, 2023
2 parents 29da05a + 91388f1 commit d58f02b
Show file tree
Hide file tree
Showing 32 changed files with 592 additions and 632 deletions.
42 changes: 23 additions & 19 deletions build-support/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
Expand All @@ -25,33 +23,45 @@ buildscript {
plugins {
`kotlin-dsl`
`java-gradle-plugin`
kotlin("jvm") version "1.9.10"
}

repositories {
mavenCentral()
google()
gradlePluginPortal()
}

dependencies {
add("compileOnly", kotlin("gradle-plugin"))
add("compileOnly", kotlin("gradle-plugin-api"))
compileOnly(libs.kotlin.gradleApi)
implementation(libs.pluginz.android)
implementation(libs.pluginz.binaryCompatibilityValidator)
implementation(libs.pluginz.kotlin)
implementation(libs.vanniktechPublishPlugin)
implementation(libs.pluginz.dokka)
implementation(libs.kotlin.serialization)
implementation(libs.pluginz.buildConfig)
implementation(libs.pluginz.spotless)
implementation(libs.pluginz.kotlinSerialization)
implementation(libs.pluginz.shadow)
implementation(libs.pluginz.buildConfig)
implementation(libs.guava)

// Expose the generated version catalog API to the plugin.
implementation(files(libs::class.java.superclass.protectionDomain.codeSource.location))
}

gradlePlugin {
plugins {
create("com.squareup.wire.build.logic") {
id = "com.squareup.wire.build.logic"
implementationClass = "BuildLogic"
create("wireBuild") {
id = "com.squareup.wire.build"
displayName = "Wire Build plugin"
description = "Gradle plugin for Wire build things"
implementationClass = "com.squareup.wire.buildsupport.WireBuildPlugin"
}
}
}

rootProject.plugins.withType(NodeJsRootPlugin::class) {
// 16+ required for Apple Silicon support
// https://youtrack.jetbrains.com/issue/KT-49109#focus=Comments-27-5259190.0-0
rootProject.extensions.getByType(NodeJsRootExtension::class).nodeVersion = "16.15.1"
}

allprojects {
repositories {
mavenCentral()
Expand All @@ -76,10 +86,4 @@ allprojects {
freeCompilerArgs += "-progressive"
}
}

tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_11.toString()
targetCompatibility = JavaVersion.VERSION_11.toString()
options.encoding = Charsets.UTF_8.toString()
}
}
4 changes: 4 additions & 0 deletions build-support/settings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Wire Settings Plugin

This is a Gradle plugin applied to the root `settings.gradle` via `includeBuild`
which automatically adds the `build-support/` Gradle plugin to all projects.
21 changes: 21 additions & 0 deletions build-support/settings/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
`kotlin-dsl`
`java-gradle-plugin`
}

gradlePlugin {
plugins {
create("wireSettings") {
id = "com.squareup.wire.settings"
displayName = "Wire settings plugin"
description = "Gradle plugin for Wire build settings"
implementationClass = "com.squareup.wire.buildsettings.WireSettingsPlugin"
}
}
}

repositories {
mavenCentral()
gradlePluginPortal()
google()
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.squareup.wire.buildsettings

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.initialization.Settings

@Suppress("unused") // Invoked reflectively by Gradle.
class WireSettingsPlugin : Plugin<Settings> {
override fun apply(target: Settings) {
fun applyWireBuildPlugin(project: Project) {
project.plugins.apply("com.squareup.wire.build")
}

target.gradle.allprojects {
if (project.path == ":") {
// The root project needs to evaluate the buildscript classpath before applying.
// Once we move to the plugins DSL in the main build we can remove this conditional.
project.afterEvaluate(::applyWireBuildPlugin)
} else {
project.beforeEvaluate(::applyWireBuildPlugin)
}
}
}
}
70 changes: 0 additions & 70 deletions build-support/src/main/kotlin/bom.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
* 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
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.gradle.api.Plugin
import org.gradle.api.Project
package com.squareup.wire.buildsupport

class BuildLogic : Plugin<Project> {
override fun apply(project: Project) {
// Do nothing.
}
interface WireBuildExtension {

/**
* Enable artifact publishing and Dokka documentation generation.
*
* The published `artifactId` will be set to the project name.
*/
fun publishing()
}
Loading

0 comments on commit d58f02b

Please sign in to comment.