Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Gradle to do more of the work in our Gradle plugin #2838

Merged
merged 7 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 5 additions & 40 deletions wire-gradle-plugin/api/wire-gradle-plugin.api
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@ public class com/squareup/wire/gradle/CustomOutput : com/squareup/wire/gradle/Wi
public synthetic fun toTarget (Ljava/lang/String;)Lcom/squareup/wire/schema/Target;
}

public final class com/squareup/wire/gradle/InputLocation : java/io/Serializable {
public static final field Companion Lcom/squareup/wire/gradle/InputLocation$Companion;
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public static final fun get (Lorg/gradle/api/Project;Ljava/lang/String;)Lcom/squareup/wire/gradle/InputLocation;
public static final fun get (Lorg/gradle/api/Project;Ljava/lang/String;Ljava/lang/String;)Lcom/squareup/wire/gradle/InputLocation;
public final fun getBase ()Ljava/lang/String;
public final fun getPath ()Ljava/lang/String;
}

public final class com/squareup/wire/gradle/InputLocation$Companion {
public final fun get (Lorg/gradle/api/Project;Ljava/lang/String;)Lcom/squareup/wire/gradle/InputLocation;
public final fun get (Lorg/gradle/api/Project;Ljava/lang/String;Ljava/lang/String;)Lcom/squareup/wire/gradle/InputLocation;
}

public class com/squareup/wire/gradle/JavaOutput : com/squareup/wire/gradle/WireOutput {
public fun <init> ()V
public final fun getAndroid ()Z
Expand Down Expand Up @@ -114,15 +100,9 @@ public class com/squareup/wire/gradle/WireExtension {
public final fun eventListenerFactoryClasses ()Ljava/util/Set;
public final fun getDryRun ()Z
public final fun getOutputs ()Ljava/util/List;
public final fun getProtoJars ()Ljava/util/Set;
public final fun getProtoLibrary ()Z
public final fun getProtoPaths ()Ljava/util/Set;
public final fun getProtoTrees ()Ljava/util/Set;
public final fun getRejectUnusedRootsOrPrunes ()Z
public final fun getRules ()Ljava/lang/String;
public final fun getSourceJars ()Ljava/util/Set;
public final fun getSourcePaths ()Ljava/util/Set;
public final fun getSourceTrees ()Ljava/util/Set;
Comment on lines -123 to -125
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically breaking but I'm assuming these APIs that are really supposed to be called from user land?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly. These should have always been implementation details.

public final fun java (Lorg/gradle/api/Action;)V
public final fun kotlin (Lorg/gradle/api/Action;)V
public final fun move (Lorg/gradle/api/Action;)V
Expand Down Expand Up @@ -152,21 +132,9 @@ public class com/squareup/wire/gradle/WireExtension {
public final fun untilVersion (Ljava/lang/String;)V
}

public class com/squareup/wire/gradle/WireExtension$ProtoRootSet {
public fun <init> ()V
public final class com/squareup/wire/gradle/WireExtension$ProtoRootSet {
public final fun exclude ([Ljava/lang/String;)V
public final fun getExcludes ()Ljava/util/List;
public final fun getIncludes ()Ljava/util/List;
public final fun getSrcDirs ()Ljava/util/List;
public final fun getSrcJar ()Ljava/lang/String;
public final fun getSrcJarAsExternalModuleDependency ()Lorg/gradle/api/provider/Provider;
public final fun getSrcProject ()Ljava/lang/String;
public final fun getSrcProjectDependency ()Lorg/gradle/api/internal/catalog/DelegatingProjectDependency;
public final fun include ([Ljava/lang/String;)V
public final fun setSrcJar (Ljava/lang/String;)V
public final fun setSrcJarAsExternalModuleDependency (Lorg/gradle/api/provider/Provider;)V
public final fun setSrcProject (Ljava/lang/String;)V
public final fun setSrcProjectDependency (Lorg/gradle/api/internal/catalog/DelegatingProjectDependency;)V
public final fun srcDir (Ljava/lang/String;)V
public final fun srcDirs ([Ljava/lang/String;)V
public final fun srcJar (Ljava/lang/String;)V
Expand All @@ -192,22 +160,22 @@ public final class com/squareup/wire/gradle/WirePlugin : org/gradle/api/Plugin {
}

public abstract class com/squareup/wire/gradle/WireTask : org/gradle/api/tasks/SourceTask {
public static final field Companion Lcom/squareup/wire/gradle/WireTask$Companion;
public fun <init> (Lorg/gradle/api/model/ObjectFactory;)V
public fun <init> (Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/api/internal/file/FileOperations;)V
public final fun generateWireFiles ()V
public abstract fun getBuildDirProperty ()Lorg/gradle/api/file/DirectoryProperty;
public final fun getDryRun ()Lorg/gradle/api/provider/Property;
public abstract fun getEventListenerFactories ()Lorg/gradle/api/provider/ListProperty;
public abstract fun getInputFiles ()Lorg/gradle/api/file/ConfigurableFileCollection;
public abstract fun getMoves ()Lorg/gradle/api/provider/ListProperty;
public abstract fun getOnlyVersion ()Lorg/gradle/api/provider/Property;
public abstract fun getOpaques ()Lorg/gradle/api/provider/ListProperty;
public abstract fun getOutputDirectories ()Lorg/gradle/api/file/ConfigurableFileCollection;
public final fun getPermitPackageCycles ()Lorg/gradle/api/provider/Property;
public final fun getPluginVersion ()Lorg/gradle/api/provider/Property;
public abstract fun getProjectDependencies ()Lorg/gradle/api/file/ConfigurableFileCollection;
public abstract fun getProjectDependenciesJvmConfiguration ()Lorg/gradle/api/file/ConfigurableFileCollection;
public abstract fun getProjectDirProperty ()Lorg/gradle/api/file/DirectoryProperty;
public abstract fun getProtoLibraryOutput ()Lorg/gradle/api/file/DirectoryProperty;
public abstract fun getProtoPathConfiguration ()Lorg/gradle/api/file/ConfigurableFileCollection;
public abstract fun getProtoSourceConfiguration ()Lorg/gradle/api/file/ConfigurableFileCollection;
public abstract fun getPrunes ()Lorg/gradle/api/provider/ListProperty;
public final fun getRejectUnusedRootsOrPrunes ()Lorg/gradle/api/provider/Property;
public abstract fun getRoots ()Lorg/gradle/api/provider/ListProperty;
Expand All @@ -218,6 +186,3 @@ public abstract class com/squareup/wire/gradle/WireTask : org/gradle/api/tasks/S
public abstract fun getUntilVersion ()Lorg/gradle/api/provider/Property;
}

public final class com/squareup/wire/gradle/WireTask$Companion {
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,14 @@
package com.squareup.wire.gradle

import com.squareup.wire.internal.Serializable
import okio.Path.Companion.toOkioPath
import okio.Path.Companion.toPath
import org.gradle.api.Project

class InputLocation private constructor(
/** The base of this location; typically a directory or .jar file. */
val base: String,

/** The path to this location relative to [base]. */
internal data class InputLocation(
/** The path to the directory or .jar. This might not exist until the [WireTask] runs! */
val path: String,
) : Serializable {
companion object {
@JvmStatic
fun get(project: Project, path: String): InputLocation {
// We store [path] relative to the [project] in order to not invalidate the cache when we
// don't have to.
return InputLocation("", project.relativePath(path))
}

@JvmStatic
fun get(
project: Project,
base: String,
path: String,
): InputLocation {
val basePath = base.toPath()

// On Windows, a dependency could live on another drive. If that's a case,
// `project.relativePath` will throw so we don't try to optimize its reference.
@Suppress("NAME_SHADOWING")
val base = if (basePath.isAbsolute && project.buildDir.toOkioPath().root != basePath.root) {
base
} else {
// We store [base] relative to the [project] in order to not invalidate the cache when we
// don't have to.
project.relativePath(base)
}
/** Files to include, following `PatternFilterable` syntax. */
val includes: List<String>,

return InputLocation(base.trimEnd('/'), path)
}
}
}
/** Files to exclude, following `PatternFilterable` syntax. */
val excludes: List<String>,
) : Serializable
Loading