Skip to content

Commit

Permalink
Merge pull request #60 from LikeTheSalad/release/2.7.0
Browse files Browse the repository at this point in the history
Release/2.7.0
  • Loading branch information
LikeTheSalad authored Jan 7, 2024
2 parents 01c4a78 + 8fc248c commit 72c5cec
Show file tree
Hide file tree
Showing 112 changed files with 345 additions and 355 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log
==========

Version 2.7.0 *(07-01-2024)*
---

* Updating utilities.
* Refactor to adapt to new utilities.
* Using version catalogs.

Version 2.5.0 *(15-08-2023)*
---

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ In your `App's build.gradle` file you have to add the following line after the a
one:

```groovy
id "com.likethesalad.stem" version "2.5.0"
id "com.likethesalad.stem" version "2.7.0"
```

Example:
Expand All @@ -355,7 +355,7 @@ Example:
// App's build.gradle file
plugins {
id "com.android.application"
id "com.likethesalad.stem" version "2.5.0"
id "com.likethesalad.stem" version "2.7.0"
}
android {
Expand All @@ -372,7 +372,7 @@ can do so by applying a "producer" version of Stem into them like so:
// Android library's build.gradle file
plugins {
id "com.android.library"
id "com.likethesalad.stem-library" version "2.5.0"
id "com.likethesalad.stem-library" version "2.7.0"
}
android {
Expand Down
42 changes: 2 additions & 40 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
buildscript {
ext {
kotlin_version = '1.9.22'
pluginMetadataTool_version = '1.0.0'
}
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
google()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.likethesalad.tools:plugin-metadata-producer:$pluginMetadataTool_version"
classpath "com.github.gmazzo.buildconfig:plugin:5.3.2"
classpath 'com.likethesalad.tools:artifact-publisher:2.0.2'
}
plugins {
alias(libs.plugins.artifactPublisher)
}

apply plugin: "artifact-publisher"

artifactPublisher {
displayName = "Android Stem"
url = "https://github.com/LikeTheSalad/android-stem"
Expand All @@ -29,23 +11,3 @@ artifactPublisher {
}

description = "This is a Gradle plugin for Android applications which resolves XML string references in other XML strings."
group = 'com.likethesalad.android'
version = "2.6.1"

ext {
dagger_version = '2.50'
androidBuild_version = '8.2.1'
testingUtilities_version = '1.0.8'
resourceLocator_version = '2.1.0'
androidTools_version = "1.5.1"
androidBuild_test_version = '8.2.1'
}

allprojects {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
google()
}
}
22 changes: 7 additions & 15 deletions common-tools/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
plugins {
id 'java-library'
id 'org.jetbrains.kotlin.jvm'
id 'kotlin-kapt'
alias(libs.plugins.java.library)
}

dependencies {
api gradleApi()
api "com.likethesalad.tools.resources:string-android-resource-locator:$resourceLocator_version"
api "com.likethesalad.tools:android-tools-plugin:$androidTools_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
testImplementation "com.likethesalad.tools.testing:unit-testing:$testingUtilities_version"
api libs.resourceLocator
implementation libs.androidCompatApi
testImplementation libs.unitTesting
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
libConventions {
setJavaVersion("11")
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.likethesalad.android.templates.common.configuration

import com.likethesalad.android.templates.common.plugins.extension.StemExtension
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class StemConfiguration @Inject constructor(private val extension: StemExtension) {
class StemConfiguration(private val extension: StemExtension) {

fun searchForTemplatesInLanguages(): Boolean {
return extension.includeLocalizedOnlyTemplates.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package com.likethesalad.android.templates.common.plugins

import com.likethesalad.android.string.resources.locator.StringResourceLocatorPlugin
import com.likethesalad.android.templates.common.plugins.extension.StemExtension
import com.likethesalad.tools.android.plugin.base.AndroidToolsPluginConsumer
import com.likethesalad.android.templates.common.utils.Logger
import com.likethesalad.plugins.agpbrigde.base.AndroidBridgePluginConsumer
import com.likethesalad.tools.resource.locator.android.extension.AndroidResourceLocatorExtension
import org.gradle.api.Project

abstract class BaseTemplatesProcessorPlugin : AndroidToolsPluginConsumer() {
abstract class BaseTemplatesProcessorPlugin : AndroidBridgePluginConsumer() {

protected lateinit var stringsLocatorExtension: AndroidResourceLocatorExtension
lateinit var extension: StemExtension
Expand All @@ -18,6 +19,7 @@ abstract class BaseTemplatesProcessorPlugin : AndroidToolsPluginConsumer() {
override fun apply(project: Project) {
validateHostProjectValidForThisPlugin(project)
super.apply(project)
Logger.init(project.logger)
project.plugins.apply(StringResourceLocatorPlugin::class.java)
extension = createExtension(project)
stringsLocatorExtension = project.extensions.getByType(AndroidResourceLocatorExtension::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import javax.inject.Inject

@Suppress("UnstableApiUsage")
open class StemExtension @Inject constructor(private val objectFactory: ObjectFactory) {
open class StemExtension @Inject constructor(objectFactory: ObjectFactory) {
val includeLocalizedOnlyTemplates: Property<Boolean> = objectFactory.property(Boolean::class.java)

init {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.likethesalad.android.templates.common.tasks.identifier

import com.likethesalad.android.templates.common.plugins.extension.StemExtension
import com.likethesalad.android.templates.common.tasks.BaseTask
import com.likethesalad.android.templates.common.tasks.identifier.action.TemplatesIdentifierAction
import com.likethesalad.android.templates.common.utils.upperFirst
Expand Down Expand Up @@ -34,7 +35,8 @@ open class TemplatesIdentifierTask @Inject constructor(private val args: Args) :

@TaskAction
fun execute() {
val action = args.actionFactory.create(
val action = TemplatesIdentifierAction.create(
args.stemExtension,
args.localResources,
outputFile.get().asFile
)
Expand All @@ -43,6 +45,6 @@ open class TemplatesIdentifierTask @Inject constructor(private val args: Args) :

data class Args(
val localResources: ResourcesProvider,
val actionFactory: TemplatesIdentifierAction.Factory
val stemExtension: StemExtension
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.likethesalad.android.templates.common.tasks.identifier.action

import com.likethesalad.android.templates.common.configuration.StemConfiguration
import com.likethesalad.android.templates.common.plugins.extension.StemExtension
import com.likethesalad.android.templates.common.tasks.identifier.data.TemplateItem
import com.likethesalad.android.templates.common.tasks.identifier.data.TemplateItemsSerializer
import com.likethesalad.android.templates.common.utils.CommonConstants
Expand All @@ -9,26 +10,27 @@ import com.likethesalad.tools.resource.api.android.impl.AndroidResourceType
import com.likethesalad.tools.resource.api.android.modules.string.StringAndroidResource
import com.likethesalad.tools.resource.api.collection.ResourceCollection
import com.likethesalad.tools.resource.locator.android.extension.configuration.data.ResourcesProvider
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import java.io.File

class TemplatesIdentifierAction @AssistedInject constructor(
@Assisted private val localResources: ResourcesProvider,
@Assisted private val outputFile: File,
private val configuration: StemConfiguration,
private val templateItemsSerializer: TemplateItemsSerializer
class TemplatesIdentifierAction private constructor(
private val localResources: ResourcesProvider,
private val outputFile: File,
private val configuration: StemConfiguration
) {

@AssistedFactory
interface Factory {
fun create(localResources: ResourcesProvider, outputFile: File): TemplatesIdentifierAction
companion object {
fun create(
stemExtension: StemExtension,
localResources: ResourcesProvider,
outputFile: File
): TemplatesIdentifierAction {
return TemplatesIdentifierAction(localResources, outputFile, StemConfiguration(stemExtension))
}
}

fun execute() {
val templates = getTemplatesFromResources()
outputFile.writeText(templateItemsSerializer.serialize(templates))
outputFile.writeText(TemplateItemsSerializer.serialize(templates))
}

private fun getTemplatesFromResources(): List<TemplateItem> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
package com.likethesalad.android.templates.common.tasks.identifier.data

import javax.inject.Inject
import javax.inject.Singleton
object TemplateItemsSerializer {

@Singleton
class TemplateItemsSerializer @Inject constructor() {

companion object {
private const val LIST_SEPARATOR = ","
private const val SINGLE_ITEM_VALUES_SEPARATOR = ":"
}
private const val LIST_SEPARATOR = ","
private const val SINGLE_ITEM_VALUES_SEPARATOR = ":"

fun serialize(templates: List<TemplateItem>): String {
return templates.distinct()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package com.likethesalad.android.templates.common.utils

import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject

class Logger @AssistedInject constructor(
@Assisted private val javaClass: Class<out Any>,
private val gradleLogger: org.gradle.api.logging.Logger
class Logger private constructor(
private val gradleLogger: org.gradle.api.logging.Logger,
private val hostClass: Class<out Any>
) {

@AssistedFactory
interface Factory {
fun create(javaClass: Class<out Any>): Logger
companion object {
private var gradleLogger: org.gradle.api.logging.Logger? = null

fun init(gradleLogger: org.gradle.api.logging.Logger) {
this.gradleLogger = gradleLogger
}

fun create(hostClass: Class<out Any>): Logger {
return Logger(gradleLogger!!, hostClass)
}
}

private val prefix by lazy {
"[STEM] - ${javaClass.name} - "
"[STEM] - ${hostClass.name} - "
}

fun debug(message: String, vararg args: Any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import org.junit.Test

class TemplateItemsSerializerTest {

private val templateItemsSerializer = TemplateItemsSerializer()

@Test
fun `Convert template items to string`() {
val item1 = TemplateItem("template1", "string")
val item2 = TemplateItem("template2", "integer")

val result = templateItemsSerializer.serialize(listOf(item1, item2))
val result = TemplateItemsSerializer.serialize(listOf(item1, item2))

Truth.assertThat(result).isEqualTo("template1:string,template2:integer")
}
Expand All @@ -25,7 +23,7 @@ class TemplateItemsSerializerTest {
val item2 = TemplateItem("template2", "integer")
val item3 = TemplateItem("template1", "string")

val result = templateItemsSerializer.serialize(listOf(item1, item2, item3))
val result = TemplateItemsSerializer.serialize(listOf(item1, item2, item3))

Truth.assertThat(result).isEqualTo("template1:string,template2:integer")
}
Expand All @@ -34,7 +32,7 @@ class TemplateItemsSerializerTest {
fun `Convert string to template items`() {
val string = "template2:string,template5:integer,template1:dimen"

val result = templateItemsSerializer.deserialize(string)
val result = TemplateItemsSerializer.deserialize(string)

Truth.assertThat(result).containsExactly(
TemplateItem("template2", "string"),
Expand All @@ -45,7 +43,7 @@ class TemplateItemsSerializerTest {

@Test
fun `Get empty list when deserializing empty string`() {
val result = templateItemsSerializer.deserialize("")
val result = TemplateItemsSerializer.deserialize("")

Truth.assertThat(result).isEmpty()
}
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
kotlin.code.style=official
kotlin.code.style=official
group=com.likethesalad.android
version=2.7.0
25 changes: 25 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[versions]
project-utilities = "3.1.0"
dagger = "2.50"
android = "8.2.1"

[libraries]
resourceLocator = "com.likethesalad.tools.resources:string-android-resource-locator:2.2.2"
androidCompatApi = { module = "com.likethesalad.tools:agp-compatibility-api", version.ref = "project-utilities" }
dagger = { module = "com.google.dagger:dagger", version.ref = "dagger" }
dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" }
metadataConsumer = "com.likethesalad.tools:plugin-metadata-consumer:1.0.0"
unitTesting = { module = "com.likethesalad.tools:unit-testing", version.ref = "project-utilities" }
byteBuddy = "net.bytebuddy:byte-buddy:1.14.11"
android-plugin = { module = "com.android.tools.build:gradle", version.ref = "android" }
classGraph = "io.github.classgraph:classgraph:4.8.165"
gson = "com.google.code.gson:gson:2.10.1"
zip4j = "net.lingala.zip4j:zip4j:2.11.5"
robolectric = "org.robolectric:robolectric:4.11.1"

[plugins]
java-library = { id = "com.likethesalad.tools.java-library", version.ref = "project-utilities" }
artifactPublisher = { id = "com.likethesalad.artifact-publisher", version = "3.1.0" }
buildConfig = { id = "com.github.gmazzo.buildconfig", version = "5.3.2" }
androidTestTools = { id = "com.likethesalad.tools.android-compilation-testing", version.ref = "project-utilities" }
android-application = { id = "com.android.application", version.ref = "android" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 72c5cec

Please sign in to comment.