From 6a72406e685e21fa0410d7b3e432d53d3bc494d4 Mon Sep 17 00:00:00 2001 From: Daymon Date: Wed, 10 Jan 2024 13:58:39 -0600 Subject: [PATCH 1/5] Implement release plugin --- .github/workflows/check_for_api_changes.yml | 10 +- generativeai/released.api => api/0.1.0.api | 1 - api/0.1.1.api | 292 ++++++++++++++++++ generativeai/build.gradle.kts | 1 + plugins/README.md | 35 ++- plugins/build.gradle.kts | 4 + .../com/google/gradle/plugins/ApiPlugin.kt | 33 +- .../google/gradle/plugins/ChangelogPlugin.kt | 10 +- .../google/gradle/plugins/ReleasePlugin.kt | 87 ++++++ .../com/google/gradle/tasks/CopyFileTask.kt | 50 +++ .../gradle/tasks/MakeReleaseNotesTask.kt | 8 +- .../google/gradle/tasks/VersionBumpTask.kt | 70 +++++ .../java/com/google/gradle/util/gradle.kt | 56 +++- 13 files changed, 613 insertions(+), 44 deletions(-) rename generativeai/released.api => api/0.1.0.api (99%) create mode 100644 api/0.1.1.api create mode 100644 plugins/src/main/java/com/google/gradle/plugins/ReleasePlugin.kt create mode 100644 plugins/src/main/java/com/google/gradle/tasks/CopyFileTask.kt create mode 100644 plugins/src/main/java/com/google/gradle/tasks/VersionBumpTask.kt diff --git a/.github/workflows/check_for_api_changes.yml b/.github/workflows/check_for_api_changes.yml index 85f916f4..1989236f 100644 --- a/.github/workflows/check_for_api_changes.yml +++ b/.github/workflows/check_for_api_changes.yml @@ -18,12 +18,12 @@ jobs: distribution: temurin cache: gradle - - name: Update released.api + - name: Export the api file run: | - ./gradlew updateApi --no-daemon + ./gradlew exportApi --no-daemon - - name: Save released.api from master - run: mv generativeai/released.api ~/released.api + - name: Save exported.api from master + run: mv generativeai/exported.api ~/exported.api - name: Checkout branch uses: actions/checkout@v3.5.3 @@ -36,7 +36,7 @@ jobs: cache: gradle - name: Copy saved api to branch - run: mv ~/released.api generativeai/released.api + run: mv ~/exported.api generativeai/exported.api - name: Run api warning task run: | diff --git a/generativeai/released.api b/api/0.1.0.api similarity index 99% rename from generativeai/released.api rename to api/0.1.0.api index 42af08c0..c02f5705 100644 --- a/generativeai/released.api +++ b/api/0.1.0.api @@ -287,4 +287,3 @@ public final class com/google/ai/client/generativeai/type/UnknownException : com public fun (Ljava/lang/String;Ljava/lang/Throwable;)V public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V } - diff --git a/api/0.1.1.api b/api/0.1.1.api new file mode 100644 index 00000000..cfb46d60 --- /dev/null +++ b/api/0.1.1.api @@ -0,0 +1,292 @@ +public final class com/google/ai/client/generativeai/BuildConfig { + public static final field BUILD_TYPE Ljava/lang/String; + public static final field DEBUG Z + public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String; + public static final field VERSION_NAME Ljava/lang/String; + public fun ()V +} + +public final class com/google/ai/client/generativeai/Chat { + public fun (Lcom/google/ai/client/generativeai/GenerativeModel;Ljava/util/List;)V + public synthetic fun (Lcom/google/ai/client/generativeai/GenerativeModel;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getHistory ()Ljava/util/List; + public final fun sendMessage (Landroid/graphics/Bitmap;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun sendMessage (Lcom/google/ai/client/generativeai/type/Content;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun sendMessage (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun sendMessageStream (Landroid/graphics/Bitmap;)Lkotlinx/coroutines/flow/Flow; + public final fun sendMessageStream (Lcom/google/ai/client/generativeai/type/Content;)Lkotlinx/coroutines/flow/Flow; + public final fun sendMessageStream (Ljava/lang/String;)Lkotlinx/coroutines/flow/Flow; +} + +public final class com/google/ai/client/generativeai/GenerativeModel { + public fun (Ljava/lang/String;Ljava/lang/String;)V + public fun (Ljava/lang/String;Ljava/lang/String;Lcom/google/ai/client/generativeai/type/GenerationConfig;)V + public fun (Ljava/lang/String;Ljava/lang/String;Lcom/google/ai/client/generativeai/type/GenerationConfig;Ljava/util/List;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lcom/google/ai/client/generativeai/type/GenerationConfig;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun countTokens (Landroid/graphics/Bitmap;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun countTokens (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun countTokens ([Lcom/google/ai/client/generativeai/type/Content;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun generateContent (Landroid/graphics/Bitmap;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun generateContent (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun generateContent ([Lcom/google/ai/client/generativeai/type/Content;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun generateContentStream (Landroid/graphics/Bitmap;)Lkotlinx/coroutines/flow/Flow; + public final fun generateContentStream (Ljava/lang/String;)Lkotlinx/coroutines/flow/Flow; + public final fun generateContentStream ([Lcom/google/ai/client/generativeai/type/Content;)Lkotlinx/coroutines/flow/Flow; + public final fun getApiKey ()Ljava/lang/String; + public final fun getGenerationConfig ()Lcom/google/ai/client/generativeai/type/GenerationConfig; + public final fun getModelName ()Ljava/lang/String; + public final fun getSafetySettings ()Ljava/util/List; + public final fun startChat (Ljava/util/List;)Lcom/google/ai/client/generativeai/Chat; + public static synthetic fun startChat$default (Lcom/google/ai/client/generativeai/GenerativeModel;Ljava/util/List;ILjava/lang/Object;)Lcom/google/ai/client/generativeai/Chat; +} + +public abstract class com/google/ai/client/generativeai/java/ChatFutures { + public static final field Companion Lcom/google/ai/client/generativeai/java/ChatFutures$Companion; + public static final fun from (Lcom/google/ai/client/generativeai/Chat;)Lcom/google/ai/client/generativeai/java/ChatFutures; + public abstract fun sendMessage (Lcom/google/ai/client/generativeai/type/Content;)Lcom/google/common/util/concurrent/ListenableFuture; + public abstract fun sendMessageStream (Lcom/google/ai/client/generativeai/type/Content;)Lorg/reactivestreams/Publisher; +} + +public final class com/google/ai/client/generativeai/java/ChatFutures$Companion { + public final fun from (Lcom/google/ai/client/generativeai/Chat;)Lcom/google/ai/client/generativeai/java/ChatFutures; +} + +public abstract class com/google/ai/client/generativeai/java/GenerativeModelFutures { + public static final field Companion Lcom/google/ai/client/generativeai/java/GenerativeModelFutures$Companion; + public abstract fun countTokens ([Lcom/google/ai/client/generativeai/type/Content;)Lcom/google/common/util/concurrent/ListenableFuture; + public static final fun from (Lcom/google/ai/client/generativeai/GenerativeModel;)Lcom/google/ai/client/generativeai/java/GenerativeModelFutures; + public abstract fun generateContent ([Lcom/google/ai/client/generativeai/type/Content;)Lcom/google/common/util/concurrent/ListenableFuture; + public abstract fun generateContentStream ([Lcom/google/ai/client/generativeai/type/Content;)Lorg/reactivestreams/Publisher; + public abstract fun startChat ()Lcom/google/ai/client/generativeai/java/ChatFutures; + public abstract fun startChat (Ljava/util/List;)Lcom/google/ai/client/generativeai/java/ChatFutures; +} + +public final class com/google/ai/client/generativeai/java/GenerativeModelFutures$Companion { + public final fun from (Lcom/google/ai/client/generativeai/GenerativeModel;)Lcom/google/ai/client/generativeai/java/GenerativeModelFutures; +} + +public final class com/google/ai/client/generativeai/type/BlobPart : com/google/ai/client/generativeai/type/Part { + public fun (Ljava/lang/String;[B)V + public final fun getBlob ()[B + public final fun getMimeType ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/BlockReason : java/lang/Enum { + public static final field OTHER Lcom/google/ai/client/generativeai/type/BlockReason; + public static final field SAFETY Lcom/google/ai/client/generativeai/type/BlockReason; + public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/BlockReason; + public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/BlockReason; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/BlockReason; + public static fun values ()[Lcom/google/ai/client/generativeai/type/BlockReason; +} + +public final class com/google/ai/client/generativeai/type/BlockThreshold : java/lang/Enum { + public static final field LOW_AND_ABOVE Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static final field MEDIUM_AND_ABOVE Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static final field NONE Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static final field ONLY_HIGH Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static fun values ()[Lcom/google/ai/client/generativeai/type/BlockThreshold; +} + +public final class com/google/ai/client/generativeai/type/Candidate { + public final fun getCitationMetadata ()Ljava/util/List; + public final fun getContent ()Lcom/google/ai/client/generativeai/type/Content; + public final fun getFinishReason ()Lcom/google/ai/client/generativeai/type/FinishReason; + public final fun getSafetyRatings ()Ljava/util/List; +} + +public final class com/google/ai/client/generativeai/type/CitationMetadata { + public fun (IILjava/lang/String;Ljava/lang/String;)V + public final fun getEndIndex ()I + public final fun getLicense ()Ljava/lang/String; + public final fun getStartIndex ()I + public final fun getUri ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/Content { + public fun (Ljava/lang/String;Ljava/util/List;)V + public synthetic fun (Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/util/List;)V + public final fun getParts ()Ljava/util/List; + public final fun getRole ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/Content$Builder { + public fun ()V + public final fun addBlob (Ljava/lang/String;[B)Lcom/google/ai/client/generativeai/type/Content$Builder; + public final fun addImage (Landroid/graphics/Bitmap;)Lcom/google/ai/client/generativeai/type/Content$Builder; + public final fun addPart (Lcom/google/ai/client/generativeai/type/Part;)Lcom/google/ai/client/generativeai/type/Content$Builder; + public final fun addText (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/Content$Builder; + public final fun build ()Lcom/google/ai/client/generativeai/type/Content; + public final fun getParts ()Ljava/util/List; + public final fun getRole ()Ljava/lang/String; + public final fun setParts (Ljava/util/List;)V + public final fun setRole (Ljava/lang/String;)V +} + +public final class com/google/ai/client/generativeai/type/ContentKt { + public static final fun content (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/google/ai/client/generativeai/type/Content; + public static synthetic fun content$default (Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/google/ai/client/generativeai/type/Content; +} + +public final class com/google/ai/client/generativeai/type/CountTokensResponse { + public fun (I)V + public final fun component1 ()I + public final fun getTotalTokens ()I +} + +public final class com/google/ai/client/generativeai/type/FinishReason : java/lang/Enum { + public static final field MAX_TOKENS Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field OTHER Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field RECITATION Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field SAFETY Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field STOP Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/FinishReason; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/FinishReason; + public static fun values ()[Lcom/google/ai/client/generativeai/type/FinishReason; +} + +public final class com/google/ai/client/generativeai/type/GenerateContentResponse { + public fun (Ljava/util/List;Lcom/google/ai/client/generativeai/type/PromptFeedback;)V + public final fun getCandidates ()Ljava/util/List; + public final fun getPromptFeedback ()Lcom/google/ai/client/generativeai/type/PromptFeedback; + public final fun getText ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/GenerationConfig { + public static final field Companion Lcom/google/ai/client/generativeai/type/GenerationConfig$Companion; + public synthetic fun (Ljava/lang/Float;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getCandidateCount ()Ljava/lang/Integer; + public final fun getMaxOutputTokens ()Ljava/lang/Integer; + public final fun getStopSequences ()Ljava/util/List; + public final fun getTemperature ()Ljava/lang/Float; + public final fun getTopK ()Ljava/lang/Integer; + public final fun getTopP ()Ljava/lang/Float; +} + +public final class com/google/ai/client/generativeai/type/GenerationConfig$Builder { + public field candidateCount Ljava/lang/Integer; + public field maxOutputTokens Ljava/lang/Integer; + public field stopSequences Ljava/util/List; + public field temperature Ljava/lang/Float; + public field topK Ljava/lang/Integer; + public field topP Ljava/lang/Float; + public fun ()V + public final fun build ()Lcom/google/ai/client/generativeai/type/GenerationConfig; +} + +public final class com/google/ai/client/generativeai/type/GenerationConfig$Companion { + public final fun builder ()Lcom/google/ai/client/generativeai/type/GenerationConfig$Builder; +} + +public final class com/google/ai/client/generativeai/type/GenerationConfigKt { + public static final fun generationConfig (Lkotlin/jvm/functions/Function1;)Lcom/google/ai/client/generativeai/type/GenerationConfig; +} + +public abstract class com/google/ai/client/generativeai/type/GoogleGenerativeAIException : java/lang/RuntimeException { + public static final field Companion Lcom/google/ai/client/generativeai/type/GoogleGenerativeAIException$Companion; + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;Lkotlin/jvm/internal/DefaultConstructorMarker;)V +} + +public final class com/google/ai/client/generativeai/type/GoogleGenerativeAIException$Companion { + public final fun from (Ljava/lang/Throwable;)Lcom/google/ai/client/generativeai/type/GoogleGenerativeAIException; +} + +public final class com/google/ai/client/generativeai/type/HarmCategory : java/lang/Enum { + public static final field DANGEROUS_CONTENT Lcom/google/ai/client/generativeai/type/HarmCategory; + public static final field HARASSMENT Lcom/google/ai/client/generativeai/type/HarmCategory; + public static final field HATE_SPEECH Lcom/google/ai/client/generativeai/type/HarmCategory; + public static final field SEXUALLY_EXPLICIT Lcom/google/ai/client/generativeai/type/HarmCategory; + public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/HarmCategory; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/HarmCategory; + public static fun values ()[Lcom/google/ai/client/generativeai/type/HarmCategory; +} + +public final class com/google/ai/client/generativeai/type/HarmProbability : java/lang/Enum { + public static final field HIGH Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field LOW Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field MEDIUM Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field NEGLIGIBLE Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/HarmProbability; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/HarmProbability; + public static fun values ()[Lcom/google/ai/client/generativeai/type/HarmProbability; +} + +public final class com/google/ai/client/generativeai/type/ImagePart : com/google/ai/client/generativeai/type/Part { + public fun (Landroid/graphics/Bitmap;)V + public final fun getImage ()Landroid/graphics/Bitmap; +} + +public final class com/google/ai/client/generativeai/type/InvalidStateException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Ljava/lang/String;Ljava/lang/Throwable;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +} + +public abstract interface class com/google/ai/client/generativeai/type/Part { +} + +public final class com/google/ai/client/generativeai/type/PartKt { + public static final fun asBlobPartOrNull (Lcom/google/ai/client/generativeai/type/Part;)Lcom/google/ai/client/generativeai/type/BlobPart; + public static final fun asImageOrNull (Lcom/google/ai/client/generativeai/type/Part;)Landroid/graphics/Bitmap; + public static final fun asTextOrNull (Lcom/google/ai/client/generativeai/type/Part;)Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/PromptBlockedException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Lcom/google/ai/client/generativeai/type/GenerateContentResponse;Ljava/lang/Throwable;)V + public synthetic fun (Lcom/google/ai/client/generativeai/type/GenerateContentResponse;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getResponse ()Lcom/google/ai/client/generativeai/type/GenerateContentResponse; +} + +public final class com/google/ai/client/generativeai/type/PromptFeedback { + public fun (Lcom/google/ai/client/generativeai/type/BlockReason;Ljava/util/List;)V + public final fun getBlockReason ()Lcom/google/ai/client/generativeai/type/BlockReason; + public final fun getSafetyRatings ()Ljava/util/List; +} + +public final class com/google/ai/client/generativeai/type/ResponseStoppedException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Lcom/google/ai/client/generativeai/type/GenerateContentResponse;Ljava/lang/Throwable;)V + public synthetic fun (Lcom/google/ai/client/generativeai/type/GenerateContentResponse;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getResponse ()Lcom/google/ai/client/generativeai/type/GenerateContentResponse; +} + +public final class com/google/ai/client/generativeai/type/SafetyRating { + public fun (Lcom/google/ai/client/generativeai/type/HarmCategory;Lcom/google/ai/client/generativeai/type/HarmProbability;)V + public final fun getCategory ()Lcom/google/ai/client/generativeai/type/HarmCategory; + public final fun getProbability ()Lcom/google/ai/client/generativeai/type/HarmProbability; +} + +public final class com/google/ai/client/generativeai/type/SafetySetting { + public fun (Lcom/google/ai/client/generativeai/type/HarmCategory;Lcom/google/ai/client/generativeai/type/BlockThreshold;)V + public final fun getHarmCategory ()Lcom/google/ai/client/generativeai/type/HarmCategory; + public final fun getThreshold ()Lcom/google/ai/client/generativeai/type/BlockThreshold; +} + +public final class com/google/ai/client/generativeai/type/SerializationException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Ljava/lang/String;Ljava/lang/Throwable;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +} + +public final class com/google/ai/client/generativeai/type/ServerException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Ljava/lang/String;Ljava/lang/Throwable;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +} + +public final class com/google/ai/client/generativeai/type/TextPart : com/google/ai/client/generativeai/type/Part { + public fun (Ljava/lang/String;)V + public final fun getText ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/UnknownException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Ljava/lang/String;Ljava/lang/Throwable;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +} diff --git a/generativeai/build.gradle.kts b/generativeai/build.gradle.kts index cd4c3fdb..d78d3079 100644 --- a/generativeai/build.gradle.kts +++ b/generativeai/build.gradle.kts @@ -20,6 +20,7 @@ plugins { id("org.jetbrains.dokka") id("com.ncorti.ktfmt.gradle") id("changelog-plugin") + id("release-plugin") kotlin("android") kotlin("plugin.serialization") } diff --git a/plugins/README.md b/plugins/README.md index 22ad15c9..61626cf7 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -5,26 +5,26 @@ number of monotonous tasks. You can read more on these plugins and the tasks the ## ChangelogPlugin -Creates and manages changelog files. These files are used to signify changes made to the repo that +Creates and manages changelog files. These files are used to signify changes made to the repo that should invoke a release, alongside text to display in the release notes at release time. -Change files are (by default) created under the `.changes` directory at the root of the repo. +Change files are (by default) created under the `.changes` directory at the root of the repo. These files are json encoded variants of a [Changelog](./src/main/java/com/google/gradle/types/Changelog.kt) instance- which is just an organization of what impact the change had (will it invoke a patch, minor, or major bump?) and an (optional) end-user readable message to show alongside the other changes at release time. By default, the files are saved as a random sequence of four words (to avoid collisions). -During a release cycle, the `.changes` directory will be filled with change files. When it comes to -release time, these changes will be combined into a single `release_notes.md` file that contains -all the changes made- in a consumable format. After a release, the `.changes` directory will be +During a release cycle, the `.changes` directory will be filled with change files. When it comes to +release time, these changes will be combined into a single `release_notes.md` file that contains +all the changes made- in a consumable format. After a release, the `.changes` directory will be wiped, and the cycle will continue. To assist in this endeavour, the ChangelogPlugin registers an internal plugin and a few tasks: ### APIPlugin -An internal plugin (automatically added, and cannot be explicitly applied) that facilitates the +An internal plugin (automatically added, and cannot be explicitly applied) that facilitates the generation of `.api` files. #### Tasks @@ -33,8 +33,8 @@ The APIPlugin registers the two following tasks to facilitate this process: - [buildApi](./src/main/java/com/google/gradle/plugins/ApiPlugin.kt) -> Creates a `.api` file containing the public API of the project. -- [updateApi](./src/main/java/com/google/gradle/plugins/ApiPlugin.kt) -> Updates (or creates) the -`released.api` file at the project directory; keeping track of the currently released/public api. +- [exportApi](./src/main/java/com/google/gradle/plugins/ApiPlugin.kt) -> Exports the `.api` file +generated by the `buildApi` task to a file at the project directory named `exported.api`. ### Tasks @@ -72,3 +72,22 @@ The LicensePlugin registers the two following tasks to facilitate this process: a license header in present in a set of files. - [ApplyLicenseTask](./src/main/java/com/google/gradle/tasks/ApplyLicenseTask.kt) -> Applies a license header to a set of files. + +## ReleasePlugin + +Facilitates the procedures expected to be done during a release. +While the `publishAllPublicationsToMavenRepository` task is used to actually *generate* the release +artifact, this plugin registers tasks that should be ran *before* the release artifact is generated. +Effectively "preparing" the project to be released. + +### Tasks + +The ReleasePlugin registers the three following tasks: + +- [updateVersion](./src/main/java/com/google/gradle/tasks/VersionBumpTask.kt) -> Updates the project +version declared in the `gradle.properties` file to reflect the version generated by the release +notes. +- [createNewApiFile](./src/main/java/com/google/gradle/plugins/ReleasePlugin.kt) -> Creates a new +`.api` file in the root `api` directory; aligning with the current state of the public api. +- [prepareRelease](./src/main/java/com/google/gradle/plugins/ReleasePlugin.kt) -> Does everything +needed to prepare a release; creates the release notes and runs the above tasks. diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts index 90c74918..279c18c6 100644 --- a/plugins/build.gradle.kts +++ b/plugins/build.gradle.kts @@ -45,6 +45,10 @@ gradlePlugin { id = "changelog-plugin" implementationClass = "com.google.gradle.plugins.ChangelogPlugin" } + register("release-plugin") { + id = "release-plugin" + implementationClass = "com.google.gradle.plugins.ReleasePlugin" + } } } diff --git a/plugins/src/main/java/com/google/gradle/plugins/ApiPlugin.kt b/plugins/src/main/java/com/google/gradle/plugins/ApiPlugin.kt index d9b4aaf4..d3504826 100644 --- a/plugins/src/main/java/com/google/gradle/plugins/ApiPlugin.kt +++ b/plugins/src/main/java/com/google/gradle/plugins/ApiPlugin.kt @@ -16,7 +16,9 @@ package com.google.gradle.plugins +import com.google.gradle.tasks.CopyFileTask import com.google.gradle.util.android +import com.google.gradle.util.outputFile import com.google.gradle.util.release import com.google.gradle.util.tempFile import java.io.File @@ -24,21 +26,19 @@ import kotlinx.validation.KotlinApiBuildTask import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.provider.Property -import org.gradle.api.tasks.Copy import org.gradle.api.tasks.Optional import org.gradle.kotlin.dsl.create import org.gradle.kotlin.dsl.register +typealias BuildApiTask = KotlinApiBuildTask + /** * A Gradle plugin for creating `.api` files; representing the public API of the project. * - * By default, a `released.api` file (at the root of the project) will be used as a base for the - * released api. - * * Registers two tasks: * - `buildApi` -> creates a `.api` file containing the *current* public API of the project. - * - `updateApi` -> updates the `released.api` file at the project root to match the one generated by - * `buildApi`; effectively saying that the released api is up to date with the current repo state. + * - `exportApi` -> exports the file generated by `buildApi` to a `exported.api` file at the project + * directory * * @see ApiPluginExtension * @see ChangelogPluginExtension @@ -46,24 +46,19 @@ import org.gradle.kotlin.dsl.register abstract class ApiPlugin : Plugin { override fun apply(project: Project) { with(project) { - val extension = extensions.create("api").apply { commonConfiguration() } + extensions.create("api").apply { commonConfiguration() } val buildApi = registerBuildApiTask() - tasks.register("updateApi") { - val fileName = extension.apiFile.map { it.name } - val filePath = extension.apiFile.map { it.parent } - - from(buildApi) - into(filePath) - - rename { fileName.get() } + tasks.register("exportApi") { + source.set(buildApi.outputFile) + dest.set(project.file("exported.api")) } } } private fun Project.registerBuildApiTask() = - tasks.register("buildApi") { + tasks.register("buildApi") { val classes = provider { android.release.output.classesDirs } inputClassesDirs = files(classes) @@ -73,14 +68,16 @@ abstract class ApiPlugin : Plugin { context(Project) private fun ApiPluginExtension.commonConfiguration() { - apiFile.convention(file("released.api")) + val latestApiFile = project.file("api/${project.version}.api") + + apiFile.convention(latestApiFile) } } /** * Extension properties for the [ApiPlugin]. * - * @property apiFile The file to reference as (and save to) in regards to the publicly released api. + * @property apiFile The file to reference to for the publicly released api. */ abstract class ApiPluginExtension { @get:Optional abstract val apiFile: Property diff --git a/plugins/src/main/java/com/google/gradle/plugins/ChangelogPlugin.kt b/plugins/src/main/java/com/google/gradle/plugins/ChangelogPlugin.kt index e3285b70..38c6cac1 100644 --- a/plugins/src/main/java/com/google/gradle/plugins/ChangelogPlugin.kt +++ b/plugins/src/main/java/com/google/gradle/plugins/ChangelogPlugin.kt @@ -21,11 +21,12 @@ import com.google.gradle.tasks.MakeChangeTask import com.google.gradle.tasks.MakeReleaseNotesTask import com.google.gradle.tasks.WarnAboutApiChangesTask import com.google.gradle.types.Changelog -import com.google.gradle.types.ModuleVersion import com.google.gradle.types.RandomWordsGenerator import com.google.gradle.util.apply import com.google.gradle.util.buildDir import com.google.gradle.util.childFile +import com.google.gradle.util.moduleVersion +import com.google.gradle.util.orElseIfNotExists import com.google.gradle.util.outputFile import com.google.gradle.util.provideProperty import com.google.gradle.util.tempFile @@ -69,7 +70,9 @@ abstract class ChangelogPlugin : Plugin { with(project) { val extension = extensions.create("changelog").apply { commonConfiguration() } - val releasedApiFile = apiPlugin.apiFile + + val exportedApiFile = provider { file("exported.api") } + val releasedApiFile = exportedApiFile.orElseIfNotExists(apiPlugin.apiFile) val newApiFile = tasks.named("buildApi").outputFile val findChanges = @@ -108,8 +111,9 @@ abstract class ChangelogPlugin : Plugin { tasks.register("makeReleaseNotes") { onlyIf("No changelog files found") { changelogFiles.get().isNotEmpty() } + changeFiles.set(changelogFiles) - version.set(ModuleVersion.fromStringOrNull(project.version.toString())) + version.set(project.moduleVersion) outputFile.set(rootProject.buildDir("release_notes.md")) finalizedBy(deleteChangeFiles) diff --git a/plugins/src/main/java/com/google/gradle/plugins/ReleasePlugin.kt b/plugins/src/main/java/com/google/gradle/plugins/ReleasePlugin.kt new file mode 100644 index 00000000..b2279385 --- /dev/null +++ b/plugins/src/main/java/com/google/gradle/plugins/ReleasePlugin.kt @@ -0,0 +1,87 @@ +/* + * Copyright 2024 Google LLC + * + * 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 + * + * 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. + */ + +package com.google.gradle.plugins + +import com.google.gradle.tasks.CopyFileTask +import com.google.gradle.tasks.MakeReleaseNotesTask +import com.google.gradle.tasks.VersionBumpTask +import com.google.gradle.types.ModuleVersion +import com.google.gradle.util.moduleVersion +import com.google.gradle.util.outputFile +import com.google.gradle.util.readFirstLine +import java.io.File +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.named +import org.gradle.kotlin.dsl.provideDelegate +import org.gradle.kotlin.dsl.register + +/** + * A Gradle plugin for preparing the release of a [Project]. + * + * Intended to be ran before running `publishAllPublicationsToMavenRepository`. + * + * Registers three tasks: + * - `updateVersion` -> updates the project version declared in `gradle.properties` file, according + * to the release notes. + * - `createNewApiFile` -> creates a new `.api` file in the `api` directory for the release, + * aligning with the current state of the public api; for future auditing. + * - `prepareRelease` -> does everything needed to prepare a release; creates the release notes and + * runs the above tasks. + * + * If any of these tasks are ran without changelog files present, the current version declared in + * the `gradle.properties` file will be used instead. + * + * @see ApiPluginExtension + * @see ChangelogPluginExtension + */ +abstract class ReleasePlugin : Plugin { + override fun apply(project: Project) { + with(project) { + val buildApi = tasks.named("buildApi") + val makeReleaseNotes = tasks.named("makeReleaseNotes") + + val releaseNotes = makeReleaseNotes.outputFile + val releasingVersion = + releaseNotes.map { parseReleaseVersion(it) }.orElse(project.moduleVersion) + + val updateVersion = + tasks.register("updateVersion") { newVersion.set(releasingVersion) } + + val createNewApiFile = + tasks.register("createNewApiFile") { + val newApiFile = releasingVersion.map { rootProject.file("api/$it.api") } + + source.set(buildApi.outputFile) + dest.set(newApiFile) + } + + tasks.register("prepareRelease") { + group = "publishing" + + dependsOn(makeReleaseNotes, updateVersion, createNewApiFile) + } + } + } + + private fun parseReleaseVersion(releaseNotes: File): ModuleVersion { + val version = releaseNotes.readFirstLine().substringAfter("#").trim() + + return ModuleVersion.fromStringOrNull(version) + ?: throw RuntimeException("Invalid release notes version found") + } +} diff --git a/plugins/src/main/java/com/google/gradle/tasks/CopyFileTask.kt b/plugins/src/main/java/com/google/gradle/tasks/CopyFileTask.kt new file mode 100644 index 00000000..d079cac2 --- /dev/null +++ b/plugins/src/main/java/com/google/gradle/tasks/CopyFileTask.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2024 Google LLC + * + * 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 + * + * 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. + */ + +package com.google.gradle.tasks + +import java.io.File +import org.gradle.api.DefaultTask +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction + +/** + * Copies a file (or directory) from one place to another. + * + * An alternative to the standard [Copy] task provided by gradle; that allows better interop with + * providers, caching, directories, and individual files. + * + * If the file is a directory, all of its contents will be copied alongside it. + * + * ***If there is already a file or directory present at the destination, its contents will be + * overwritten.*** + * + * @property source the file or directory to copy from + * @property dest where to copy the file or directory to + */ +abstract class CopyFileTask : DefaultTask() { + @get:InputFile abstract val source: Property + + @get:OutputFile abstract val dest: Property + + @TaskAction + fun create() { + source.get().copyRecursively(dest.get(), overwrite = true) + } +} diff --git a/plugins/src/main/java/com/google/gradle/tasks/MakeReleaseNotesTask.kt b/plugins/src/main/java/com/google/gradle/tasks/MakeReleaseNotesTask.kt index 6c73c7e0..b10f4afe 100644 --- a/plugins/src/main/java/com/google/gradle/tasks/MakeReleaseNotesTask.kt +++ b/plugins/src/main/java/com/google/gradle/tasks/MakeReleaseNotesTask.kt @@ -38,10 +38,6 @@ import org.gradle.api.tasks.TaskAction * The markdown file will also have a header representing the version to be released, bumped from * the provided [version] according to the highest impact [VersionType] from the list of changes. * - * Note, that the version is ONLY bumped if the impact of any given change is more than a - * [patch][VersionType.PATCH], as the repo's current version is set to a patch bump higher than the - * currently released version by default to avoid cache conflicts when testing locally. - * * @property changeFiles the [Changelog] files to use in the release * @property version a [ModuleVersion] representing the current version of the project * @property outputFile where to save the serialized release notes to @@ -61,13 +57,11 @@ abstract class MakeReleaseNotesTask : DefaultTask() { val bump = changelogs.minBy { it.type.ordinal }.type - val version = if (bump >= VersionType.PATCH) version.get() else version.get().bump(bump) - outputFile .get() .writeText( """ - | # $version + |# ${version.get().bump(bump)} | | - ${changes.joinToString("\n - ")} """ diff --git a/plugins/src/main/java/com/google/gradle/tasks/VersionBumpTask.kt b/plugins/src/main/java/com/google/gradle/tasks/VersionBumpTask.kt new file mode 100644 index 00000000..d4e77dbc --- /dev/null +++ b/plugins/src/main/java/com/google/gradle/tasks/VersionBumpTask.kt @@ -0,0 +1,70 @@ +/* + * Copyright 2023 Google LLC + * + * 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 + * + * 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. + */ + +package com.google.gradle.tasks + +import com.google.gradle.types.ModuleVersion +import com.google.gradle.util.rewriteLines +import java.io.File +import org.gradle.api.DefaultTask +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.TaskAction +import org.gradle.kotlin.dsl.provideDelegate + +/** + * Bumps the `version` property of the specified [versionFile]. + * + * Alternatively can be used to set the version directly, by specifying a [newVersion]. + * + * @property versionFile A [File] that contains the `version` property. Defaults to the + * `gradle.properties` file at the project's root. + * @property newVersion A [ModuleVersion] of what to set to. Defaults to the project version. + */ +abstract class VersionBumpTask : DefaultTask() { + @get:[Optional InputFile] + abstract val versionFile: Property + + @get:[Optional Input] + abstract val newVersion: Property + + init { + configure() + } + + @TaskAction + fun build() { + versionFile.get().rewriteLines { + when { + it.startsWith("version=") -> "version=${newVersion.get()}" + else -> it + } + } + } + + private fun configure() { + versionFile.convention(project.file("gradle.properties")) + newVersion.convention(computeVersionBump()) + } + + private fun computeVersionBump(): ModuleVersion? { + val version: String? by project + + return version?.let { ModuleVersion.fromStringOrNull(it)?.bump() } + } +} diff --git a/plugins/src/main/java/com/google/gradle/util/gradle.kt b/plugins/src/main/java/com/google/gradle/util/gradle.kt index 8c4d95a9..3e0f0e87 100644 --- a/plugins/src/main/java/com/google/gradle/util/gradle.kt +++ b/plugins/src/main/java/com/google/gradle/util/gradle.kt @@ -16,6 +16,7 @@ package com.google.gradle.util +import com.google.gradle.types.ModuleVersion import java.io.File import org.gradle.api.DefaultTask import org.gradle.api.Plugin @@ -60,7 +61,7 @@ inline fun , C : WorkParameters> WorkQueue.submit( * fileProvider.map { File("${it.path}/$path") } * ``` */ -fun Provider.childFile(path: String) = map { File("${it.path}/$path") } +fun Provider.childFile(path: String): Provider = map { File("${it.path}/$path") } /** * Returns a new [File] under the given sub directory. @@ -131,6 +132,57 @@ val KotlinAndroidProjectExtension.release: KotlinJvmAndroidCompilation * * @param property the name of the property to look for */ -inline fun Project.provideProperty(property: String) = provider { +inline fun Project.provideProperty(property: String): Provider = provider { findProperty(property) as? T } + +/** + * Rewrites the lines of a file. + * + * The lines of the file are first read and then transformed by the provided `block` function. The + * transformed lines are then joined together with a newline character and written back to the file. + * + * If the `terminateWithNewline` parameter is set to `false`, the file will not be terminated with a + * newline character. + * + * @param terminateWithNewline Whether to terminate the file with a newline character. Defaults to + * `true`. + * @param block A function that takes a string as input and returns a new string. This function is + * used to transform the lines of the file before they are rewritten. + * + * ``` + * val file = File("my-file.txt") + * + * // Rewrite the lines of the file, replacing all spaces with tabs. + * file.rewriteLines { it.replace(" ", "\t") } + * + * // Rewrite the lines of the file, capitalizing the first letter of each word. + * file.rewriteLines { it.capitalizeWords() } + * ``` + * + * @see [readLines] + * @see [writeText] + */ +fun File.rewriteLines(terminateWithNewline: Boolean = true, block: (String) -> String) { + val newLines = readLines().map(block) + writeText(newLines.joinToString("\n").let { if (terminateWithNewline) it + "\n" else it }) +} + +/** + * Lazily reads the first line of a file. + * + * Uses a buffered reader to avoid loading the whole file in memory, and closes the file after + * reading the first line. + */ +fun File.readFirstLine(): String = bufferedReader().useLines { it.first() } + +/** Fetches the [version][Project.getVersion] of the project as a [ModuleVersion]. */ +val Project.moduleVersion: ModuleVersion + get() = + ModuleVersion.fromStringOrNull(project.version.toString()) + ?: throw RuntimeException("Invalid project version found.") + +/** Maps a file provider to an alternative provider if the original file does not exist. */ +fun Provider.orElseIfNotExists(file: Provider): Provider = map { + it.takeIf { it.exists() } ?: file.get() +} From eaca00dc559811b081a957af58771c98255eb4f2 Mon Sep 17 00:00:00 2001 From: Daymon <17409137+daymxn@users.noreply.github.com> Date: Fri, 12 Jan 2024 12:16:55 -0600 Subject: [PATCH 2/5] Update plugins/src/main/java/com/google/gradle/plugins/ReleasePlugin.kt Co-authored-by: Rodrigo Lazo --- .../src/main/java/com/google/gradle/plugins/ReleasePlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/src/main/java/com/google/gradle/plugins/ReleasePlugin.kt b/plugins/src/main/java/com/google/gradle/plugins/ReleasePlugin.kt index b2279385..71e063a7 100644 --- a/plugins/src/main/java/com/google/gradle/plugins/ReleasePlugin.kt +++ b/plugins/src/main/java/com/google/gradle/plugins/ReleasePlugin.kt @@ -31,7 +31,7 @@ import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.register /** - * A Gradle plugin for preparing the release of a [Project]. + * A Gradle plugin for preparing a release. * * Intended to be ran before running `publishAllPublicationsToMavenRepository`. * From 1f76e3162b37fb20ea1c5bd8a7c4972ac8b3193c Mon Sep 17 00:00:00 2001 From: Daymon Date: Fri, 12 Jan 2024 12:18:43 -0600 Subject: [PATCH 3/5] Address comments --- .github/workflows/check_for_api_changes.yml | 8 ++++---- plugins/README.md | 2 +- .../src/main/java/com/google/gradle/plugins/ApiPlugin.kt | 5 +++-- .../java/com/google/gradle/plugins/ChangelogPlugin.kt | 2 +- .../main/java/com/google/gradle/tasks/VersionBumpTask.kt | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/check_for_api_changes.yml b/.github/workflows/check_for_api_changes.yml index 1989236f..b3e448e3 100644 --- a/.github/workflows/check_for_api_changes.yml +++ b/.github/workflows/check_for_api_changes.yml @@ -18,12 +18,12 @@ jobs: distribution: temurin cache: gradle - - name: Export the api file + - name: Generate the api file run: | ./gradlew exportApi --no-daemon - - name: Save exported.api from master - run: mv generativeai/exported.api ~/exported.api + - name: Save public.api from master + run: mv generativeai/public.api ~/public.api - name: Checkout branch uses: actions/checkout@v3.5.3 @@ -36,7 +36,7 @@ jobs: cache: gradle - name: Copy saved api to branch - run: mv ~/exported.api generativeai/exported.api + run: mv ~/public.api generativeai/public.api - name: Run api warning task run: | diff --git a/plugins/README.md b/plugins/README.md index 61626cf7..74d7eb03 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -34,7 +34,7 @@ The APIPlugin registers the two following tasks to facilitate this process: - [buildApi](./src/main/java/com/google/gradle/plugins/ApiPlugin.kt) -> Creates a `.api` file containing the public API of the project. - [exportApi](./src/main/java/com/google/gradle/plugins/ApiPlugin.kt) -> Exports the `.api` file -generated by the `buildApi` task to a file at the project directory named `exported.api`. +generated by the `buildApi` task to a file at the project directory named `public.api`. ### Tasks diff --git a/plugins/src/main/java/com/google/gradle/plugins/ApiPlugin.kt b/plugins/src/main/java/com/google/gradle/plugins/ApiPlugin.kt index d3504826..33b7a811 100644 --- a/plugins/src/main/java/com/google/gradle/plugins/ApiPlugin.kt +++ b/plugins/src/main/java/com/google/gradle/plugins/ApiPlugin.kt @@ -26,6 +26,7 @@ import kotlinx.validation.KotlinApiBuildTask import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.provider.Property +import org.gradle.api.tasks.Copy import org.gradle.api.tasks.Optional import org.gradle.kotlin.dsl.create import org.gradle.kotlin.dsl.register @@ -37,7 +38,7 @@ typealias BuildApiTask = KotlinApiBuildTask * * Registers two tasks: * - `buildApi` -> creates a `.api` file containing the *current* public API of the project. - * - `exportApi` -> exports the file generated by `buildApi` to a `exported.api` file at the project + * - `exportApi` -> exports the file generated by `buildApi` to a `public.api` file at the project * directory * * @see ApiPluginExtension @@ -52,7 +53,7 @@ abstract class ApiPlugin : Plugin { tasks.register("exportApi") { source.set(buildApi.outputFile) - dest.set(project.file("exported.api")) + dest.set(project.file("public.api")) } } } diff --git a/plugins/src/main/java/com/google/gradle/plugins/ChangelogPlugin.kt b/plugins/src/main/java/com/google/gradle/plugins/ChangelogPlugin.kt index 38c6cac1..52a8d062 100644 --- a/plugins/src/main/java/com/google/gradle/plugins/ChangelogPlugin.kt +++ b/plugins/src/main/java/com/google/gradle/plugins/ChangelogPlugin.kt @@ -71,7 +71,7 @@ abstract class ChangelogPlugin : Plugin { val extension = extensions.create("changelog").apply { commonConfiguration() } - val exportedApiFile = provider { file("exported.api") } + val exportedApiFile = provider { file("public.api") } val releasedApiFile = exportedApiFile.orElseIfNotExists(apiPlugin.apiFile) val newApiFile = tasks.named("buildApi").outputFile diff --git a/plugins/src/main/java/com/google/gradle/tasks/VersionBumpTask.kt b/plugins/src/main/java/com/google/gradle/tasks/VersionBumpTask.kt index d4e77dbc..8b6d4404 100644 --- a/plugins/src/main/java/com/google/gradle/tasks/VersionBumpTask.kt +++ b/plugins/src/main/java/com/google/gradle/tasks/VersionBumpTask.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 4c8aa82c28818f257e240d8deaf9bc80fe546bd1 Mon Sep 17 00:00:00 2001 From: Daymon Date: Fri, 12 Jan 2024 12:28:22 -0600 Subject: [PATCH 4/5] Fix ci failure --- .github/workflows/check_for_api_changes.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_for_api_changes.yml b/.github/workflows/check_for_api_changes.yml index b3e448e3..d27fd2d9 100644 --- a/.github/workflows/check_for_api_changes.yml +++ b/.github/workflows/check_for_api_changes.yml @@ -20,7 +20,7 @@ jobs: - name: Generate the api file run: | - ./gradlew exportApi --no-daemon + ./gradlew generativeai:exportApi --no-daemon - name: Save public.api from master run: mv generativeai/public.api ~/public.api @@ -40,7 +40,7 @@ jobs: - name: Run api warning task run: | - ./gradlew warnAboutApiChanges --no-daemon + ./gradlew generativeai:warnAboutApiChanges --no-daemon - name: Add PR Comment if: ${{ hashFiles('api_changes.md') != '' }} From 8ed0bbf4705a2245cd3aede53000b0a7791c5fc3 Mon Sep 17 00:00:00 2001 From: Daymon Date: Tue, 16 Jan 2024 13:04:07 -0600 Subject: [PATCH 5/5] Add missing api files --- api/0.1.0.api | 15 +-- api/0.1.2.api | 289 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 294 insertions(+), 10 deletions(-) create mode 100644 api/0.1.2.api diff --git a/api/0.1.0.api b/api/0.1.0.api index c02f5705..17e6332b 100644 --- a/api/0.1.0.api +++ b/api/0.1.0.api @@ -1,11 +1,3 @@ -public final class com/google/ai/client/generativeai/BuildConfig { - public static final field BUILD_TYPE Ljava/lang/String; - public static final field DEBUG Z - public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String; - public static final field VERSION_NAME Ljava/lang/String; - public fun ()V -} - public final class com/google/ai/client/generativeai/Chat { public fun (Lcom/google/ai/client/generativeai/GenerativeModel;Ljava/util/List;)V public synthetic fun (Lcom/google/ai/client/generativeai/GenerativeModel;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -43,7 +35,6 @@ public final class com/google/ai/client/generativeai/GenerativeModel { public abstract class com/google/ai/client/generativeai/java/ChatFutures { public static final field Companion Lcom/google/ai/client/generativeai/java/ChatFutures$Companion; public static final fun from (Lcom/google/ai/client/generativeai/Chat;)Lcom/google/ai/client/generativeai/java/ChatFutures; - public abstract fun getChat ()Lcom/google/ai/client/generativeai/Chat; public abstract fun sendMessage (Lcom/google/ai/client/generativeai/type/Content;)Lcom/google/common/util/concurrent/ListenableFuture; public abstract fun sendMessageStream (Lcom/google/ai/client/generativeai/type/Content;)Lorg/reactivestreams/Publisher; } @@ -58,7 +49,6 @@ public abstract class com/google/ai/client/generativeai/java/GenerativeModelFutu public static final fun from (Lcom/google/ai/client/generativeai/GenerativeModel;)Lcom/google/ai/client/generativeai/java/GenerativeModelFutures; public abstract fun generateContent ([Lcom/google/ai/client/generativeai/type/Content;)Lcom/google/common/util/concurrent/ListenableFuture; public abstract fun generateContentStream ([Lcom/google/ai/client/generativeai/type/Content;)Lorg/reactivestreams/Publisher; - public abstract fun getGenerativeModel ()Lcom/google/ai/client/generativeai/GenerativeModel; public abstract fun startChat ()Lcom/google/ai/client/generativeai/java/ChatFutures; public abstract fun startChat (Ljava/util/List;)Lcom/google/ai/client/generativeai/java/ChatFutures; } @@ -78,6 +68,7 @@ public final class com/google/ai/client/generativeai/type/BlockReason : java/lan public static final field SAFETY Lcom/google/ai/client/generativeai/type/BlockReason; public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/BlockReason; public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/BlockReason; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/BlockReason; public static fun values ()[Lcom/google/ai/client/generativeai/type/BlockReason; } @@ -88,6 +79,7 @@ public final class com/google/ai/client/generativeai/type/BlockThreshold : java/ public static final field NONE Lcom/google/ai/client/generativeai/type/BlockThreshold; public static final field ONLY_HIGH Lcom/google/ai/client/generativeai/type/BlockThreshold; public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/BlockThreshold; public static fun values ()[Lcom/google/ai/client/generativeai/type/BlockThreshold; } @@ -147,6 +139,7 @@ public final class com/google/ai/client/generativeai/type/FinishReason : java/la public static final field STOP Lcom/google/ai/client/generativeai/type/FinishReason; public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/FinishReason; public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/FinishReason; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/FinishReason; public static fun values ()[Lcom/google/ai/client/generativeai/type/FinishReason; } @@ -204,6 +197,7 @@ public final class com/google/ai/client/generativeai/type/HarmCategory : java/la public static final field HATE_SPEECH Lcom/google/ai/client/generativeai/type/HarmCategory; public static final field SEXUALLY_EXPLICIT Lcom/google/ai/client/generativeai/type/HarmCategory; public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/HarmCategory; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/HarmCategory; public static fun values ()[Lcom/google/ai/client/generativeai/type/HarmCategory; } @@ -215,6 +209,7 @@ public final class com/google/ai/client/generativeai/type/HarmProbability : java public static final field NEGLIGIBLE Lcom/google/ai/client/generativeai/type/HarmProbability; public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/HarmProbability; public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/HarmProbability; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/HarmProbability; public static fun values ()[Lcom/google/ai/client/generativeai/type/HarmProbability; } diff --git a/api/0.1.2.api b/api/0.1.2.api new file mode 100644 index 00000000..c02f5705 --- /dev/null +++ b/api/0.1.2.api @@ -0,0 +1,289 @@ +public final class com/google/ai/client/generativeai/BuildConfig { + public static final field BUILD_TYPE Ljava/lang/String; + public static final field DEBUG Z + public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String; + public static final field VERSION_NAME Ljava/lang/String; + public fun ()V +} + +public final class com/google/ai/client/generativeai/Chat { + public fun (Lcom/google/ai/client/generativeai/GenerativeModel;Ljava/util/List;)V + public synthetic fun (Lcom/google/ai/client/generativeai/GenerativeModel;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getHistory ()Ljava/util/List; + public final fun sendMessage (Landroid/graphics/Bitmap;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun sendMessage (Lcom/google/ai/client/generativeai/type/Content;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun sendMessage (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun sendMessageStream (Landroid/graphics/Bitmap;)Lkotlinx/coroutines/flow/Flow; + public final fun sendMessageStream (Lcom/google/ai/client/generativeai/type/Content;)Lkotlinx/coroutines/flow/Flow; + public final fun sendMessageStream (Ljava/lang/String;)Lkotlinx/coroutines/flow/Flow; +} + +public final class com/google/ai/client/generativeai/GenerativeModel { + public fun (Ljava/lang/String;Ljava/lang/String;)V + public fun (Ljava/lang/String;Ljava/lang/String;Lcom/google/ai/client/generativeai/type/GenerationConfig;)V + public fun (Ljava/lang/String;Ljava/lang/String;Lcom/google/ai/client/generativeai/type/GenerationConfig;Ljava/util/List;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lcom/google/ai/client/generativeai/type/GenerationConfig;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun countTokens (Landroid/graphics/Bitmap;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun countTokens (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun countTokens ([Lcom/google/ai/client/generativeai/type/Content;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun generateContent (Landroid/graphics/Bitmap;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun generateContent (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun generateContent ([Lcom/google/ai/client/generativeai/type/Content;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun generateContentStream (Landroid/graphics/Bitmap;)Lkotlinx/coroutines/flow/Flow; + public final fun generateContentStream (Ljava/lang/String;)Lkotlinx/coroutines/flow/Flow; + public final fun generateContentStream ([Lcom/google/ai/client/generativeai/type/Content;)Lkotlinx/coroutines/flow/Flow; + public final fun getApiKey ()Ljava/lang/String; + public final fun getGenerationConfig ()Lcom/google/ai/client/generativeai/type/GenerationConfig; + public final fun getModelName ()Ljava/lang/String; + public final fun getSafetySettings ()Ljava/util/List; + public final fun startChat (Ljava/util/List;)Lcom/google/ai/client/generativeai/Chat; + public static synthetic fun startChat$default (Lcom/google/ai/client/generativeai/GenerativeModel;Ljava/util/List;ILjava/lang/Object;)Lcom/google/ai/client/generativeai/Chat; +} + +public abstract class com/google/ai/client/generativeai/java/ChatFutures { + public static final field Companion Lcom/google/ai/client/generativeai/java/ChatFutures$Companion; + public static final fun from (Lcom/google/ai/client/generativeai/Chat;)Lcom/google/ai/client/generativeai/java/ChatFutures; + public abstract fun getChat ()Lcom/google/ai/client/generativeai/Chat; + public abstract fun sendMessage (Lcom/google/ai/client/generativeai/type/Content;)Lcom/google/common/util/concurrent/ListenableFuture; + public abstract fun sendMessageStream (Lcom/google/ai/client/generativeai/type/Content;)Lorg/reactivestreams/Publisher; +} + +public final class com/google/ai/client/generativeai/java/ChatFutures$Companion { + public final fun from (Lcom/google/ai/client/generativeai/Chat;)Lcom/google/ai/client/generativeai/java/ChatFutures; +} + +public abstract class com/google/ai/client/generativeai/java/GenerativeModelFutures { + public static final field Companion Lcom/google/ai/client/generativeai/java/GenerativeModelFutures$Companion; + public abstract fun countTokens ([Lcom/google/ai/client/generativeai/type/Content;)Lcom/google/common/util/concurrent/ListenableFuture; + public static final fun from (Lcom/google/ai/client/generativeai/GenerativeModel;)Lcom/google/ai/client/generativeai/java/GenerativeModelFutures; + public abstract fun generateContent ([Lcom/google/ai/client/generativeai/type/Content;)Lcom/google/common/util/concurrent/ListenableFuture; + public abstract fun generateContentStream ([Lcom/google/ai/client/generativeai/type/Content;)Lorg/reactivestreams/Publisher; + public abstract fun getGenerativeModel ()Lcom/google/ai/client/generativeai/GenerativeModel; + public abstract fun startChat ()Lcom/google/ai/client/generativeai/java/ChatFutures; + public abstract fun startChat (Ljava/util/List;)Lcom/google/ai/client/generativeai/java/ChatFutures; +} + +public final class com/google/ai/client/generativeai/java/GenerativeModelFutures$Companion { + public final fun from (Lcom/google/ai/client/generativeai/GenerativeModel;)Lcom/google/ai/client/generativeai/java/GenerativeModelFutures; +} + +public final class com/google/ai/client/generativeai/type/BlobPart : com/google/ai/client/generativeai/type/Part { + public fun (Ljava/lang/String;[B)V + public final fun getBlob ()[B + public final fun getMimeType ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/BlockReason : java/lang/Enum { + public static final field OTHER Lcom/google/ai/client/generativeai/type/BlockReason; + public static final field SAFETY Lcom/google/ai/client/generativeai/type/BlockReason; + public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/BlockReason; + public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/BlockReason; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/BlockReason; + public static fun values ()[Lcom/google/ai/client/generativeai/type/BlockReason; +} + +public final class com/google/ai/client/generativeai/type/BlockThreshold : java/lang/Enum { + public static final field LOW_AND_ABOVE Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static final field MEDIUM_AND_ABOVE Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static final field NONE Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static final field ONLY_HIGH Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/BlockThreshold; + public static fun values ()[Lcom/google/ai/client/generativeai/type/BlockThreshold; +} + +public final class com/google/ai/client/generativeai/type/Candidate { + public final fun getCitationMetadata ()Ljava/util/List; + public final fun getContent ()Lcom/google/ai/client/generativeai/type/Content; + public final fun getFinishReason ()Lcom/google/ai/client/generativeai/type/FinishReason; + public final fun getSafetyRatings ()Ljava/util/List; +} + +public final class com/google/ai/client/generativeai/type/CitationMetadata { + public fun (IILjava/lang/String;Ljava/lang/String;)V + public final fun getEndIndex ()I + public final fun getLicense ()Ljava/lang/String; + public final fun getStartIndex ()I + public final fun getUri ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/Content { + public fun (Ljava/lang/String;Ljava/util/List;)V + public synthetic fun (Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/util/List;)V + public final fun getParts ()Ljava/util/List; + public final fun getRole ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/Content$Builder { + public fun ()V + public final fun addBlob (Ljava/lang/String;[B)Lcom/google/ai/client/generativeai/type/Content$Builder; + public final fun addImage (Landroid/graphics/Bitmap;)Lcom/google/ai/client/generativeai/type/Content$Builder; + public final fun addPart (Lcom/google/ai/client/generativeai/type/Part;)Lcom/google/ai/client/generativeai/type/Content$Builder; + public final fun addText (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/Content$Builder; + public final fun build ()Lcom/google/ai/client/generativeai/type/Content; + public final fun getParts ()Ljava/util/List; + public final fun getRole ()Ljava/lang/String; + public final fun setParts (Ljava/util/List;)V + public final fun setRole (Ljava/lang/String;)V +} + +public final class com/google/ai/client/generativeai/type/ContentKt { + public static final fun content (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/google/ai/client/generativeai/type/Content; + public static synthetic fun content$default (Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/google/ai/client/generativeai/type/Content; +} + +public final class com/google/ai/client/generativeai/type/CountTokensResponse { + public fun (I)V + public final fun component1 ()I + public final fun getTotalTokens ()I +} + +public final class com/google/ai/client/generativeai/type/FinishReason : java/lang/Enum { + public static final field MAX_TOKENS Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field OTHER Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field RECITATION Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field SAFETY Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field STOP Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/FinishReason; + public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/FinishReason; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/FinishReason; + public static fun values ()[Lcom/google/ai/client/generativeai/type/FinishReason; +} + +public final class com/google/ai/client/generativeai/type/GenerateContentResponse { + public fun (Ljava/util/List;Lcom/google/ai/client/generativeai/type/PromptFeedback;)V + public final fun getCandidates ()Ljava/util/List; + public final fun getPromptFeedback ()Lcom/google/ai/client/generativeai/type/PromptFeedback; + public final fun getText ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/GenerationConfig { + public static final field Companion Lcom/google/ai/client/generativeai/type/GenerationConfig$Companion; + public synthetic fun (Ljava/lang/Float;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getCandidateCount ()Ljava/lang/Integer; + public final fun getMaxOutputTokens ()Ljava/lang/Integer; + public final fun getStopSequences ()Ljava/util/List; + public final fun getTemperature ()Ljava/lang/Float; + public final fun getTopK ()Ljava/lang/Integer; + public final fun getTopP ()Ljava/lang/Float; +} + +public final class com/google/ai/client/generativeai/type/GenerationConfig$Builder { + public field candidateCount Ljava/lang/Integer; + public field maxOutputTokens Ljava/lang/Integer; + public field stopSequences Ljava/util/List; + public field temperature Ljava/lang/Float; + public field topK Ljava/lang/Integer; + public field topP Ljava/lang/Float; + public fun ()V + public final fun build ()Lcom/google/ai/client/generativeai/type/GenerationConfig; +} + +public final class com/google/ai/client/generativeai/type/GenerationConfig$Companion { + public final fun builder ()Lcom/google/ai/client/generativeai/type/GenerationConfig$Builder; +} + +public final class com/google/ai/client/generativeai/type/GenerationConfigKt { + public static final fun generationConfig (Lkotlin/jvm/functions/Function1;)Lcom/google/ai/client/generativeai/type/GenerationConfig; +} + +public abstract class com/google/ai/client/generativeai/type/GoogleGenerativeAIException : java/lang/RuntimeException { + public static final field Companion Lcom/google/ai/client/generativeai/type/GoogleGenerativeAIException$Companion; + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;Lkotlin/jvm/internal/DefaultConstructorMarker;)V +} + +public final class com/google/ai/client/generativeai/type/GoogleGenerativeAIException$Companion { + public final fun from (Ljava/lang/Throwable;)Lcom/google/ai/client/generativeai/type/GoogleGenerativeAIException; +} + +public final class com/google/ai/client/generativeai/type/HarmCategory : java/lang/Enum { + public static final field DANGEROUS_CONTENT Lcom/google/ai/client/generativeai/type/HarmCategory; + public static final field HARASSMENT Lcom/google/ai/client/generativeai/type/HarmCategory; + public static final field HATE_SPEECH Lcom/google/ai/client/generativeai/type/HarmCategory; + public static final field SEXUALLY_EXPLICIT Lcom/google/ai/client/generativeai/type/HarmCategory; + public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/HarmCategory; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/HarmCategory; + public static fun values ()[Lcom/google/ai/client/generativeai/type/HarmCategory; +} + +public final class com/google/ai/client/generativeai/type/HarmProbability : java/lang/Enum { + public static final field HIGH Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field LOW Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field MEDIUM Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field NEGLIGIBLE Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field UNKNOWN Lcom/google/ai/client/generativeai/type/HarmProbability; + public static final field UNSPECIFIED Lcom/google/ai/client/generativeai/type/HarmProbability; + public static fun valueOf (Ljava/lang/String;)Lcom/google/ai/client/generativeai/type/HarmProbability; + public static fun values ()[Lcom/google/ai/client/generativeai/type/HarmProbability; +} + +public final class com/google/ai/client/generativeai/type/ImagePart : com/google/ai/client/generativeai/type/Part { + public fun (Landroid/graphics/Bitmap;)V + public final fun getImage ()Landroid/graphics/Bitmap; +} + +public final class com/google/ai/client/generativeai/type/InvalidStateException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Ljava/lang/String;Ljava/lang/Throwable;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +} + +public abstract interface class com/google/ai/client/generativeai/type/Part { +} + +public final class com/google/ai/client/generativeai/type/PartKt { + public static final fun asBlobPartOrNull (Lcom/google/ai/client/generativeai/type/Part;)Lcom/google/ai/client/generativeai/type/BlobPart; + public static final fun asImageOrNull (Lcom/google/ai/client/generativeai/type/Part;)Landroid/graphics/Bitmap; + public static final fun asTextOrNull (Lcom/google/ai/client/generativeai/type/Part;)Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/PromptBlockedException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Lcom/google/ai/client/generativeai/type/GenerateContentResponse;Ljava/lang/Throwable;)V + public synthetic fun (Lcom/google/ai/client/generativeai/type/GenerateContentResponse;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getResponse ()Lcom/google/ai/client/generativeai/type/GenerateContentResponse; +} + +public final class com/google/ai/client/generativeai/type/PromptFeedback { + public fun (Lcom/google/ai/client/generativeai/type/BlockReason;Ljava/util/List;)V + public final fun getBlockReason ()Lcom/google/ai/client/generativeai/type/BlockReason; + public final fun getSafetyRatings ()Ljava/util/List; +} + +public final class com/google/ai/client/generativeai/type/ResponseStoppedException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Lcom/google/ai/client/generativeai/type/GenerateContentResponse;Ljava/lang/Throwable;)V + public synthetic fun (Lcom/google/ai/client/generativeai/type/GenerateContentResponse;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getResponse ()Lcom/google/ai/client/generativeai/type/GenerateContentResponse; +} + +public final class com/google/ai/client/generativeai/type/SafetyRating { + public fun (Lcom/google/ai/client/generativeai/type/HarmCategory;Lcom/google/ai/client/generativeai/type/HarmProbability;)V + public final fun getCategory ()Lcom/google/ai/client/generativeai/type/HarmCategory; + public final fun getProbability ()Lcom/google/ai/client/generativeai/type/HarmProbability; +} + +public final class com/google/ai/client/generativeai/type/SafetySetting { + public fun (Lcom/google/ai/client/generativeai/type/HarmCategory;Lcom/google/ai/client/generativeai/type/BlockThreshold;)V + public final fun getHarmCategory ()Lcom/google/ai/client/generativeai/type/HarmCategory; + public final fun getThreshold ()Lcom/google/ai/client/generativeai/type/BlockThreshold; +} + +public final class com/google/ai/client/generativeai/type/SerializationException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Ljava/lang/String;Ljava/lang/Throwable;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +} + +public final class com/google/ai/client/generativeai/type/ServerException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Ljava/lang/String;Ljava/lang/Throwable;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +} + +public final class com/google/ai/client/generativeai/type/TextPart : com/google/ai/client/generativeai/type/Part { + public fun (Ljava/lang/String;)V + public final fun getText ()Ljava/lang/String; +} + +public final class com/google/ai/client/generativeai/type/UnknownException : com/google/ai/client/generativeai/type/GoogleGenerativeAIException { + public fun (Ljava/lang/String;Ljava/lang/Throwable;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +}