Skip to content
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
2 changes: 1 addition & 1 deletion apk-viewer-plugin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<meta-data
android:name="plugin.version"
android:value="1.0.3" />
android:value="${pluginVersion}" />

<meta-data
android:name="plugin.description"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ class PluginListAdapter(
binding.apply {
pluginName.text = plugin.metadata.name
pluginDescription.text = plugin.metadata.description
pluginVersion.text = "v${plugin.metadata.version}"
val version = plugin.metadata.version
val segments = version.split('.')
pluginVersion.text = if (segments.size > 3) {
"v${segments.take(3).joinToString(".")}..."
} else {
"v$version"
}
pluginAuthor.text = "by ${plugin.metadata.author}"

// Set status
Expand Down
2 changes: 1 addition & 1 deletion keystore-generator-plugin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<meta-data
android:name="plugin.version"
android:value="1.0.4" />
android:value="${pluginVersion}" />

<meta-data
android:name="plugin.description"
Expand Down
2 changes: 1 addition & 1 deletion markdown-preview-plugin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<meta-data
android:name="plugin.version"
android:value="1.0.1" />
android:value="${pluginVersion}" />

<meta-data
android:name="plugin.description"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.itsaky.androidide.plugins.build

import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import java.io.File
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

class PluginBuilder : Plugin<Project> {

Expand All @@ -17,6 +20,8 @@ class PluginBuilder : Plugin<Project> {
}

companion object {
private val TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss")
private const val DEFAULT_VERSION = "1.0.0"
private const val POSITIVE_HASH_MASK = 0x7FFFFFFF
private const val PACKAGE_ID_RANGE = 0x7D
private const val MIN_PACKAGE_ID = 0x02
Expand All @@ -28,6 +33,22 @@ class PluginBuilder : Plugin<Project> {
PluginBuilderExtension::class.java
)

val androidExtension = target.extensions.getByType(ApplicationExtension::class.java)
val componentsExtension = target.extensions.getByType(
ApplicationAndroidComponentsExtension::class.java
)
componentsExtension.onVariants { variant ->
val resolvedVersion = if (extension.pluginVersion.isPresent) {
extension.pluginVersion.get()
} else {
val baseVersion = androidExtension.defaultConfig.versionName ?: DEFAULT_VERSION
val timestamp = LocalDateTime.now().format(TIMESTAMP_FORMATTER)
Comment thread
jatezzz marked this conversation as resolved.
"$baseVersion-${variant.name}.$timestamp"
}
variant.manifestPlaceholders.put("pluginVersion", resolvedVersion)
target.logger.lifecycle("PluginBuilder: version resolved to '$resolvedVersion'")
}

target.afterEvaluate {
configurePackageId(target)
BuildVariant.values().forEach { variant ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import org.gradle.api.provider.Property

abstract class PluginBuilderExtension {
abstract val pluginName: Property<String>
abstract val pluginVersion: Property<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fun pluginAndroidManifest(data: PluginTemplateData): String {

<meta-data
android:name="plugin.version"
android:value="${data.version}" />
android:value="${'$'}{pluginVersion}" />

<meta-data
android:name="plugin.description"
Expand Down
Loading