├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── themes.xml
│ │ │ │ └── colors.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── mipmap-anydpi-v33
│ │ │ │ └── ic_launcher.xml
│ │ │ ├── xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ │ └── io
│ │ │ │ └── spherelabs
│ │ │ │ └── buildable
│ │ │ │ ├── Person.kt
│ │ │ │ ├── ui
│ │ │ │ └── theme
│ │ │ │ │ ├── Color.kt
│ │ │ │ │ ├── Shape.kt
│ │ │ │ │ ├── Type.kt
│ │ │ │ │ └── Theme.kt
│ │ │ │ ├── Student.kt
│ │ │ │ ├── BookDto.kt
│ │ │ │ ├── Example.kt
│ │ │ │ ├── UserEntity.kt
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── io
│ │ │ └── spherelabs
│ │ │ └── buildable
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── io
│ │ └── spherelabs
│ │ └── buildable
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── docs
└── images
│ ├── cover-buildable.png
│ ├── buildable - cover.png
│ ├── BuildableFactory - Code Usage.png
│ └── BuildableMapper - Code Usage 2.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── spotless
└── spotless.gradle
├── .github
└── workflows
│ ├── gradle-caches
│ └── action.yml
│ ├── publish.yml
│ ├── publish-snapshot.yml
│ └── android.yml
├── tools
├── hooks
│ └── pre-commit
└── scripts
│ ├── publish-root.gradle
│ └── publish-module.gradle
├── settings.gradle
├── LICENSE
├── gradle.properties
├── gradlew.bat
├── .editorconfig
├── gradlew
└── README.md
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | buildable
3 |
--------------------------------------------------------------------------------
/docs/images/cover-buildable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/docs/images/cover-buildable.png
--------------------------------------------------------------------------------
/docs/images/buildable - cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/docs/images/buildable - cover.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/docs/images/BuildableFactory - Code Usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/docs/images/BuildableFactory - Code Usage.png
--------------------------------------------------------------------------------
/docs/images/BuildableMapper - Code Usage 2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/docs/images/BuildableMapper - Code Usage 2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/getspherelabs/buildable/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/Person.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable
2 |
3 | import io.spherelabs.factory.BuildableFactory
4 |
5 |
6 | @BuildableFactory
7 | interface Person {
8 | fun sleep()
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 19 18:03:30 KST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
9 |
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/Student.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable
2 |
3 | import io.spherelabs.factory.BuildableComponent
4 |
5 |
6 | @BuildableComponent
7 | class Student : Person {
8 | override fun sleep() {
9 | println("Student sleeps 5 hours")
10 | }
11 | }
12 |
13 | fun main() {
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
12 |
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/BookDto.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable
2 |
3 | import io.spherelabs.mapperannotation.BuildableMapper
4 |
5 | @BuildableMapper(
6 | from = [NotificationEntity::class],
7 | to = [NotificationEntity::class]
8 | )
9 | data class NotificationDto(
10 | val name: String
11 | )
12 |
13 | data class NotificationEntity(
14 | val name: String
15 | )
16 |
17 | fun main() {
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/test/java/io/spherelabs/buildable/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable
2 |
3 | import junit.framework.TestCase.assertEquals
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * See [testing documentation](http://d.android.com/tools/testing).
10 | */
11 | class ExampleUnitTest {
12 | @Test
13 | fun addition_isCorrect() {
14 | assertEquals(4, 2 + 2)
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/Example.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable
2 |
3 | import io.spherelabs.factory.BuildableComponent
4 | import io.spherelabs.factory.BuildableFactory
5 |
6 |
7 | @BuildableFactory
8 | interface Car {
9 | fun drive()
10 | }
11 |
12 | @BuildableComponent
13 | class Nexia : Car {
14 | override fun drive() {
15 | println("Nexia is driving...")
16 | }
17 | }
18 |
19 | @BuildableComponent
20 | class Matiz : Car {
21 | override fun drive() {
22 | println("Matiz is driving...")
23 | }
24 | }
25 |
26 | fun main() {
27 | val nexia = CarFactory(CarType.NEXIA)
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/UserEntity.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable
2 |
3 | import io.spherelabs.mapperannotation.BuildableMapper
4 |
5 | @BuildableMapper(
6 | [CouponApproveDomain::class]
7 | )
8 | data class CouponApproveDto(
9 | val tid: String
10 | )
11 |
12 | @BuildableMapper(
13 | [CouponApproveDto::class]
14 | )
15 | data class CouponApproveDomain(
16 | val tid: String
17 | )
18 |
19 | @BuildableMapper(
20 | [ExchangeDomain::class]
21 | )
22 | data class ExchangeString(
23 | val name: String
24 | )
25 |
26 | data class ExchangeDomain(
27 | val name: String
28 | )
29 |
30 | fun main() {
31 | }
32 |
--------------------------------------------------------------------------------
/spotless/spotless.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.diffplug.spotless"
2 |
3 | spotless {
4 | encoding 'UTF-8'
5 | kotlin {
6 | target "**/*.kt"
7 | targetExclude "**/build/**/*.kt"
8 | ktlint()
9 | trimTrailingWhitespace()
10 | endWithNewline()
11 | }
12 |
13 | java {
14 | importOrder()
15 | removeUnusedImports()
16 | googleJavaFormat()
17 | trimTrailingWhitespace()
18 | endWithNewline()
19 | }
20 | kotlinGradle {
21 | target "*.gradle.kts"
22 | ktlint()
23 | trimTrailingWhitespace()
24 | endWithNewline()
25 | }
26 | format "xml", {
27 | target "**/*.xml"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/.github/workflows/gradle-caches/action.yml:
--------------------------------------------------------------------------------
1 | name: 'Gradle Cache'
2 | description: 'Cache Gradle Build Cache to improve workflow execution time'
3 | inputs:
4 | key-prefix:
5 | description: 'A prefix on the key used to store/restore cache'
6 | required: true
7 | runs:
8 | using: "composite"
9 | steps:
10 | - uses: actions/cache@v3.0.11
11 | with:
12 | path: |
13 | ~/.gradle/caches
14 | ~/.gradle/wrapper
15 | key: ${{ runner.os }}-${{ inputs.key-prefix }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
16 | restore-keys: |
17 | ${{ runner.os }}-${{ inputs.key-prefix }}-
18 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/io/spherelabs/buildable/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import androidx.test.platform.app.InstrumentationRegistry
5 | import junit.framework.TestCase.assertEquals
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | /**
10 | * Instrumented test, which will execute on an Android device.
11 | *
12 | * See [testing documentation](http://d.android.com/tools/testing).
13 | */
14 | @RunWith(AndroidJUnit4::class)
15 | class ExampleInstrumentedTest {
16 | @Test
17 | fun useAppContext() {
18 | // Context of the app under test.
19 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
20 | assertEquals("io.behzod.buildable", appContext.packageName)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/tools/hooks/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo "*********************************************************"
3 | echo "Running git pre-commit hook. Running Static analysis... "
4 | echo "*********************************************************"
5 |
6 | ./gradlew ktlintCheck
7 |
8 | status=$?
9 |
10 | if [ "$status" = 0 ] ; then
11 | echo "Static analysis found no problems."
12 | exit 0
13 | else
14 | echo "*********************************************************"
15 | echo " ******************************************** "
16 | echo 1>&2 "Static analysis found violations it could not fix."
17 | echo "Run ./gradlew ktlintFormat to fix formatting related issues..."
18 | echo " ******************************************** "
19 | echo "*********************************************************"
20 | exit 1
21 | fi
22 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | maven { url 'https://jitpack.io' }
7 | maven { url "https://plugins.gradle.org/m2/" }
8 | }
9 | }
10 | dependencyResolutionManagement {
11 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
12 | repositories {
13 | google()
14 | mavenCentral()
15 | maven { url 'https://jitpack.io' }
16 | maven { url "https://plugins.gradle.org/m2/" }
17 | }
18 | }
19 | rootProject.name = "buildable"
20 | include ':app'
21 | include ':buildable-annotations'
22 | include ':buildable-processors'
23 | include ':buildable-annotations:mapper-core'
24 | include ':buildable-annotations:factory-core'
25 | include ':buildable-annotations:state'
26 | include ':buildable-processors:mapper'
27 | include ':buildable-processors:factory'
28 |
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
29 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
14 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Sphere Labs
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 |
3 | on:
4 | release:
5 | types: [released]
6 |
7 | jobs:
8 | publish:
9 |
10 | name: Release build and publish
11 | runs-on: ubuntu-22.04
12 |
13 | steps:
14 | - name: Check out code
15 | uses: actions/checkout@v3.1.0
16 | - name: Set up JDK 11
17 | uses: actions/setup-java@v3.6.0
18 | with:
19 | distribution: adopt
20 | java-version: 11
21 |
22 | - name: Release build
23 | # assembleRelease for all modules, excluding non-library modules: samples, docs
24 | run: ./gradlew assembleRelease -x :app:assembleRelease
25 | - name: Source jar
26 | run: ./gradlew androidSourcesJar
27 | - name: Publish to MavenCentral
28 | run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
29 | env:
30 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
31 | OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
32 | SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
33 | SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
34 | SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
35 | SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
36 |
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun BuildableTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
45 |
--------------------------------------------------------------------------------
/.github/workflows/publish-snapshot.yml:
--------------------------------------------------------------------------------
1 | name: Publish Snapshot builds
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | pull_request:
7 | branches: [ "main" ]
8 |
9 | jobs:
10 | publish:
11 |
12 | name: Snapshot build and publish
13 | runs-on: ubuntu-22.04
14 | steps:
15 | - name: Check out code
16 | uses: actions/checkout@v3.1.0
17 | - name: Set up JDK 11
18 | uses: actions/setup-java@v3.6.0
19 | with:
20 | distribution: adopt
21 | java-version: 11
22 |
23 | - name: Release build
24 | # assembleRelease for all modules, excluding non-library modules: samples, docs
25 | run: ./gradlew assembleRelease -x :app:assembleRelease
26 | - name: Source jar
27 | run: ./gradlew androidSourcesJar
28 | - name: Publish to MavenCentral
29 | run: ./gradlew publishReleasePublicationToSonatypeRepository
30 | env:
31 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
32 | OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
33 | SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
34 | SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
35 | SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
36 | SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
37 | SNAPSHOT: true
38 |
--------------------------------------------------------------------------------
/app/src/main/java/io/spherelabs/buildable/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package io.spherelabs.buildable
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.material.MaterialTheme
8 | import androidx.compose.material.Surface
9 | import androidx.compose.material.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.ui.Modifier
12 | import androidx.compose.ui.tooling.preview.Preview
13 | import io.spherelabs.buildable.ui.theme.BuildableTheme
14 |
15 | class MainActivity : ComponentActivity() {
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 | setContent {
19 | BuildableTheme {
20 | // A surface container using the 'background' color from the theme
21 | Surface(
22 | modifier = Modifier.fillMaxSize(),
23 | color = MaterialTheme.colors.background
24 | ) {
25 | Greeting("Android")
26 | }
27 | }
28 | }
29 | }
30 | }
31 |
32 | @Composable
33 | fun Greeting(name: String) {
34 | Text(text = "Hello $name!")
35 | }
36 |
37 | @Preview(showBackground = true)
38 | @Composable
39 | fun DefaultPreview() {
40 | BuildableTheme {
41 | Greeting("Android")
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
24 | org.gradle.caching=true
25 |
--------------------------------------------------------------------------------
/tools/scripts/publish-root.gradle:
--------------------------------------------------------------------------------
1 | // Create variables with empty default values
2 |
3 | ext["signing.keyId"] = ''
4 | ext["signing.password"] = ''
5 | ext["signing.key"] = ''
6 | ext["ossrhUsername"] = ''
7 | ext["ossrhPassword"] = ''
8 | ext["sonatypeStagingProfileId"] = ''
9 |
10 | File secretPropsFile = project.rootProject.file('local.properties')
11 | if (secretPropsFile.exists()) {
12 | // Read local.properties file first if it exists
13 | Properties p = new Properties()
14 | new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
15 | p.each { name, value -> ext[name] = value }
16 | } else {
17 | // Use system environment variables
18 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
19 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
20 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
21 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
22 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
23 | ext["signing.key"] = System.getenv('SIGNING_KEY')
24 | ext["snapshot"] = System.getenv('SNAPSHOT')
25 | }
26 |
27 | nexusPublishing {
28 | repositories {
29 | sonatype {
30 | stagingProfileId = sonatypeStagingProfileId
31 | username = ossrhUsername
32 | password = ossrhPassword
33 |
34 | nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
35 | snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | pull_request:
7 | branches: [ "main" ]
8 |
9 | jobs:
10 | lint:
11 |
12 | name: ktlint
13 | runs-on: ubuntu-22.04
14 | steps:
15 | - name: Check out code
16 | uses: actions/checkout@v3.1.0
17 | - name: Set up JDK 11
18 | uses: actions/setup-java@v3.6.0
19 | with:
20 | distribution: adopt
21 | java-version: 11
22 | - uses: ./.github/workflows/gradle-caches
23 | with:
24 | key-prefix: gradle-lint
25 | - name: Ktlint
26 | run: ./gradlew ktlintCheck --scan
27 | build:
28 |
29 | name: Build
30 | runs-on: ubuntu-22.04
31 |
32 | steps:
33 | - name: Check out code
34 | uses: actions/checkout@v3.1.0
35 | - name: Set up JDK 11
36 | uses: actions/setup-java@v3.6.0
37 | with:
38 | distribution: adopt
39 | java-version: 11
40 | - uses: ./.github/workflows/gradle-caches
41 | with:
42 | key-prefix: gradle-build
43 | - name: Build
44 | run: ./gradlew assembleDebug --scan
45 | test:
46 | name: Unit tests
47 | runs-on: ubuntu-22.04
48 | steps:
49 | - name: Check out code
50 | uses: actions/checkout@v3.1.0
51 | - name: Set up JDK 11
52 | uses: actions/setup-java@v3.6.0
53 | with:
54 | distribution: adopt
55 | java-version: 11
56 | - uses: ./.github/workflows/gradle-caches
57 | with:
58 | key-prefix: gradle-test
59 | - name: Unit tests
60 | run: ./gradlew test
61 | - name: Upload test results
62 | uses: actions/upload-artifact@v3.1.0
63 | if: failure()
64 | with:
65 | name: testDebugUnitTest
66 | path: ./**/build/reports/tests/testDebugUnitTest
67 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | id 'com.google.devtools.ksp' version '1.8.10-1.0.9'
5 | }
6 |
7 | sourceSets.configureEach {
8 | kotlin.srcDir("$buildDir/generated/ksp/$name/kotlin/")
9 | }
10 |
11 |
12 | android {
13 | namespace 'io.behzod.buildable'
14 | compileSdk 33
15 |
16 | defaultConfig {
17 | applicationId "io.behzod.buildable"
18 | minSdk 24
19 | targetSdk 33
20 | versionCode 1
21 | versionName "1.0"
22 |
23 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
24 | vectorDrawables {
25 | useSupportLibrary true
26 | }
27 | }
28 |
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
33 | }
34 | debug {
35 | minifyEnabled true
36 | }
37 | }
38 |
39 | compileOptions {
40 | sourceCompatibility JavaVersion.VERSION_1_8
41 | targetCompatibility JavaVersion.VERSION_1_8
42 | }
43 | kotlinOptions {
44 | jvmTarget = '1.8'
45 | }
46 | buildFeatures {
47 | compose true
48 | }
49 | composeOptions {
50 | kotlinCompilerExtensionVersion '1.4.1'
51 | }
52 | packagingOptions {
53 | resources {
54 | excludes += '/META-INF/{AL2.0,LGPL2.1}'
55 | }
56 | }
57 | }
58 |
59 | dependencies {
60 | implementation implementation(project(':buildable-annotations:factory-core',))
61 | implementation implementation(project(':buildable-annotations:mapper-core',))
62 |
63 | ksp project(":buildable-processors:factory")
64 | ksp project(":buildable-processors:mapper")
65 |
66 | implementation 'androidx.core:core-ktx:1.9.0'
67 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
68 | implementation 'androidx.activity:activity-compose:1.3.1'
69 | implementation "androidx.compose.ui:ui:$compose_ui_version"
70 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
71 | implementation 'androidx.compose.material:material:1.2.0'
72 | testImplementation 'junit:junit:4.13.2'
73 | androidTestImplementation 'androidx.test.ext:junit:1.1.5'
74 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
75 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
76 | debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
77 | debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/tools/scripts/publish-module.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven-publish'
2 | apply plugin: 'signing'
3 | apply plugin: 'org.jetbrains.dokka'
4 |
5 | task androidSourcesJar(type: Jar) {
6 | archiveClassifier.set('sources')
7 | if (project.plugins.findPlugin("com.android.library")) {
8 | from android.sourceSets.main.java.srcDirs
9 | from android.sourceSets.main.kotlin.srcDirs
10 | } else {
11 | from sourceSets.main.java.srcDirs
12 | from sourceSets.main.kotlin.srcDirs
13 | }
14 | }
15 |
16 | tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
17 | pluginsMapConfiguration.set(
18 | ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
19 | )
20 | }
21 |
22 | task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
23 | archiveClassifier.set('javadoc')
24 | from dokkaJavadoc.outputDirectory
25 | }
26 |
27 |
28 | artifacts {
29 | archives androidSourcesJar
30 | archives javadocJar
31 | }
32 |
33 | group = PUBLISH_GROUP_ID
34 | version = PUBLISH_VERSION
35 |
36 | afterEvaluate {
37 | publishing {
38 | publications {
39 | release(MavenPublication) {
40 | groupId PUBLISH_GROUP_ID
41 | artifactId PUBLISH_ARTIFACT_ID
42 | version PUBLISH_VERSION
43 | if (project.plugins.findPlugin("com.android.library")) {
44 | from components.release
45 | } else {
46 | from components.java
47 | }
48 |
49 | artifact androidSourcesJar
50 | artifact javadocJar
51 |
52 | pom {
53 | name = PUBLISH_ARTIFACT_ID
54 | description = 'Buildable is a code generation tool'
55 | url = 'https://github.com/getspherelabs/buildable'
56 | licenses {
57 | license {
58 | name = 'Buildable License'
59 | }
60 | }
61 | developers {
62 | developer {
63 | id = 'behzod'
64 | name = 'Behzod'
65 | email = 'behzoddev@gmail.com'
66 | }
67 | }
68 |
69 | scm {
70 | connection = 'scm:git:github.com/getspherelabs/buildable.git'
71 | developerConnection = 'scm:git:ssh://github.com/getspherelabs/buildable.git'
72 | url = 'https://github.com/getspherelabs/buildable'
73 | }
74 | }
75 | }
76 | }
77 | }
78 | }
79 |
80 | signing {
81 | useInMemoryPgpKeys(
82 | rootProject.ext["signing.keyId"],
83 | rootProject.ext["signing.key"],
84 | rootProject.ext["signing.password"],
85 | )
86 | sign publishing.publications
87 | }
88 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | insert_final_newline = true
5 | indent_style = space
6 | indent_size = 2
7 |
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 |
11 | max_line_length = 120
12 | tab_width = 4
13 |
14 | [{*.kt, *.kts}]
15 | max_line_length = 140
16 | ij_kotlin_packages_to_use_import_on_demand = ^
17 | ij_continuation_indent_size = 4
18 | ij_kotlin_align_in_columns_case_branch = false
19 | ij_kotlin_align_multiline_binary_operation = false
20 | ij_kotlin_align_multiline_extends_list = false
21 | ij_kotlin_align_multiline_method_parentheses = false
22 | ij_kotlin_align_multiline_parameters = true
23 | ij_kotlin_align_multiline_parameters_in_calls = false
24 | ij_kotlin_allow_trailing_comma = false
25 | ij_kotlin_allow_trailing_comma_on_call_site = false
26 | ij_kotlin_assignment_wrap = normal
27 | ij_kotlin_blank_lines_after_class_header = 0
28 | ij_kotlin_blank_lines_around_block_when_branches = 0
29 | ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1
30 | ij_kotlin_block_comment_at_first_column = true
31 | ij_kotlin_call_parameters_new_line_after_left_paren = true
32 | ij_kotlin_call_parameters_right_paren_on_new_line = true
33 | ij_kotlin_call_parameters_wrap = on_every_item
34 | ij_kotlin_catch_on_new_line = false
35 | ij_kotlin_class_annotation_wrap = split_into_lines
36 | ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
37 | ij_kotlin_continuation_indent_for_chained_calls = false
38 | ij_kotlin_continuation_indent_for_expression_bodies = false
39 | ij_kotlin_continuation_indent_in_argument_lists = false
40 | ij_kotlin_continuation_indent_in_elvis = false
41 | ij_kotlin_continuation_indent_in_if_conditions = false
42 | ij_kotlin_continuation_indent_in_parameter_lists = false
43 | ij_kotlin_continuation_indent_in_supertype_lists = false
44 | ij_kotlin_else_on_new_line = false
45 | ij_kotlin_enum_constants_wrap = off
46 | ij_kotlin_extends_list_wrap = normal
47 | ij_kotlin_field_annotation_wrap = split_into_lines
48 | ij_kotlin_finally_on_new_line = false
49 | ij_kotlin_if_rparen_on_new_line = true
50 | ij_kotlin_import_nested_classes = false
51 | ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^
52 | ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
53 | ij_kotlin_keep_blank_lines_before_right_brace = 2
54 | ij_kotlin_keep_blank_lines_in_code = 2
55 | ij_kotlin_keep_blank_lines_in_declarations = 2
56 | ij_kotlin_keep_first_column_comment = true
57 | ij_kotlin_keep_indents_on_empty_lines = false
58 | ij_kotlin_keep_line_breaks = true
59 | ij_kotlin_lbrace_on_next_line = false
60 | ij_kotlin_line_comment_add_space = false
61 | ij_kotlin_line_comment_at_first_column = true
62 | ij_kotlin_method_annotation_wrap = split_into_lines
63 | ij_kotlin_method_call_chain_wrap = normal
64 | ij_kotlin_method_parameters_new_line_after_left_paren = true
65 | ij_kotlin_method_parameters_right_paren_on_new_line = true
66 | ij_kotlin_method_parameters_wrap = on_every_item
67 | ij_kotlin_name_count_to_use_star_import = 2147483647
68 | ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
69 | ij_kotlin_parameter_annotation_wrap = off
70 | ij_kotlin_space_after_comma = true
71 | ij_kotlin_space_after_extend_colon = true
72 | ij_kotlin_space_after_type_colon = true
73 | ij_kotlin_space_before_catch_parentheses = true
74 | ij_kotlin_space_before_comma = false
75 | ij_kotlin_space_before_extend_colon = true
76 | ij_kotlin_space_before_for_parentheses = true
77 | ij_kotlin_space_before_if_parentheses = true
78 | ij_kotlin_space_before_lambda_arrow = true
79 | ij_kotlin_space_before_type_colon = false
80 | ij_kotlin_space_before_when_parentheses = true
81 | ij_kotlin_space_before_while_parentheses = true
82 | ij_kotlin_spaces_around_additive_operators = true
83 | ij_kotlin_spaces_around_assignment_operators = true
84 | ij_kotlin_spaces_around_equality_operators = true
85 | ij_kotlin_spaces_around_function_type_arrow = true
86 | ij_kotlin_spaces_around_logical_operators = true
87 | ij_kotlin_spaces_around_multiplicative_operators = true
88 | ij_kotlin_spaces_around_range = false
89 | ij_kotlin_spaces_around_relational_operators = true
90 | ij_kotlin_spaces_around_unary_operator = false
91 | ij_kotlin_spaces_around_when_arrow = true
92 | ij_kotlin_variable_annotation_wrap = off
93 | ij_kotlin_while_on_new_line = false
94 | ij_kotlin_wrap_elvis_expressions = 1
95 | ij_kotlin_wrap_expression_body_functions = 1
96 | ij_kotlin_wrap_first_method_in_call_chain = false
97 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
Buildable
2 |
3 |
4 |
5 |
6 |
7 |
8 |
10 |
11 | ## Why Buildable?
12 |
13 | `@Buildable` is a tool designed for Kotlin that facilitates the generation of code for mappers, factories, and state classes. By automating the creation of these components, Buildable can save developers a significant amount of time and effort,
14 |
15 | ## Build Types
16 |
17 | `@Buildable` provides support for three unique build types.
18 |
19 | ### Factory
20 |
21 | Generates factory methods for creating instances of classes with complex constructors or dependencies.
22 |
23 |
24 |
25 |
26 |
27 | ### Mapper
28 |
29 | Generates mapping functions that facilitate the conversion of data between different data classes. This is particularly useful in situations where you need to map data from API responses to your application's domain models, or between different layers of your application.
30 |
31 |
32 |
33 |
34 |
35 |
36 | ### State (Working in Progress)
37 |
38 | ## Configuring Gradle
39 |
40 | In order to use [KSP (Kotlin Symbol Processing)](https://kotlinlang.org/docs/ksp-quickstart.html) and the [Buildable](https://github.com/getspherelabs/buildable) library into your project, follow the steps below.
41 |
42 | ### Enable KSP in your module
43 |
44 | To enable KSP in your module, add the KSP plugin as shown below to your module's `build.gradle` file:
45 |
46 |
47 | Kotlin (KTS)
48 |
49 | ```kotlin
50 | plugins {
51 | id("com.google.devtools.ksp") version "1.8.10-1.0.9"
52 | }
53 | ```
54 |
55 |
56 |
57 | Groovy
58 |
59 | ```kotlin
60 | plugins {
61 | id("com.google.devtools.ksp") version "1.8.10-1.0.9"
62 | }
63 | ```
64 |
65 |
66 | > **Note**: Make sure your current Kotlin version and [KSP version](https://github.com/google/ksp/releases) is the same.
67 |
68 | ## Add the Buildable library to your module
69 |
70 | Add the dependency below into your **module**'s `build.gradle` file:
71 |
72 | ```gradle
73 | dependencies {
74 | // For using @BuildableFactory
75 | implementation("io.github.behzodhalil:buildable-factory-core:1.1.0")
76 | ksp("io.github.behzodhalil:buildable-factory:1.1.0")
77 |
78 | // For using @BuildableMapper
79 | implementation("io.github.behzodhalil:buildable-mapper-core:1.1.0")
80 | ksp("io.github.behzodhalil:buildable-mapper:1.1.0")
81 | }
82 | ```
83 | ### Add source path (KSP)
84 |
85 | To access generated codes from KSP, you need to set up the source path like the below into your **module**'s `build.gradle` file:
86 |
87 |
88 | Android Kotlin (KTS)
89 |
90 | ```kotlin
91 | kotlin {
92 | sourceSets.configureEach {
93 | kotlin.srcDir("$buildDir/generated/ksp/$name/kotlin/")
94 | }
95 | }
96 | ```
97 |
98 |
99 |
100 | Android Groovy
101 |
102 | ```gradle
103 | android {
104 | applicationVariants.all { variant ->
105 | kotlin.sourceSets {
106 | def name = variant.name
107 | getByName(name) {
108 | kotlin.srcDir("build/generated/ksp/$name/kotlin")
109 | }
110 | }
111 | }
112 | }
113 | ```
114 |
115 |
116 |
117 | Pure Kotlin (KTS)
118 |
119 | ```gradle
120 | kotlin {
121 | sourceSets.main {
122 | kotlin.srcDir("build/generated/ksp/main/kotlin")
123 | }
124 | sourceSets.test {
125 | kotlin.srcDir("build/generated/ksp/test/kotlin")
126 | }
127 | }
128 | ```
129 |
130 |
131 |
132 | Pure Kotlin Groovy
133 |
134 | ```gradle
135 | kotlin {
136 | sourceSets {
137 | main.kotlin.srcDirs += 'build/generated/ksp/main/kotlin'
138 | test.kotlin.srcDirs += 'build/generated/ksp/test/kotlin'
139 | }
140 | }
141 | ```
142 |
143 |
144 | ## Usage and Examples
145 |
146 | > **Note**: In order to use the generated code, you need to execute the `./gradlew kspDebugKotlin` command or perform a project rebuild.
147 |
148 | ### BuildableFactory
149 |
150 | `@BuildableFactory` annotation aims to simplify code generation associated with the Factory Method pattern. This simplifies the management of object creation, ultimately enhancing maintainability and code readability.
151 | - `@BuildableComponent` annotation is utilized to specify the type for creating a factory pattern implementation.
152 |
153 | ```kotlin
154 | @BuildableFactory
155 | interface Car {
156 | fun drive()
157 | }
158 |
159 | @BuildableComponent
160 | class Nexia : Car {
161 | override fun drive() {
162 | println("Nexia is driving...")
163 | }
164 | }
165 |
166 | @BuildableComponent
167 | class Matiz : Car {
168 | override fun drive() {
169 | println("Matiz is driving...")
170 | }
171 | ```
172 |
173 | The example codes generate `CarFactory` and `CarTypes` for easier object management.
174 |
175 | **CarFactory (generated)**:
176 | ```kotlin
177 | public enum class CarType {
178 | NEXIA,
179 | MATIZ,
180 | }
181 |
182 | public fun CarFactory(key: CarType): Car = when (key) {
183 | CarType.NEXIA -> Nexia()
184 | CarType.MATIZ -> Matiz()
185 | }
186 | ```
187 |
188 | ### BuildableMapper
189 |
190 | `@BuildableMapper` annotation is designed to streamline code generation for mapping one class to another, making object creation management more efficient and improving overall maintainability and readability within the codebase.
191 |
192 | ```kotlin
193 | @BuildableMapper(
194 | from = [NotificationDto::class],
195 | to = [NotificationEntity::class]
196 | )
197 | data class NotificationDto(
198 | val name: String
199 | )
200 |
201 | data class NotificationEntity(
202 | val name: String
203 | )
204 | ```
205 |
206 | The example codes generate `NotificationDtoBuildableMapperExtensions.kt` for easier object management.
207 |
208 | ```kotlin
209 | fun NotificationEntity.toNotificationDto() = NotificationDto(
210 | name = this.name,
211 | )
212 |
213 | fun NotificationDto.toNotificationEntity() = NotificationEntity(
214 | name = this.name,
215 | )
216 | ```
217 |
--------------------------------------------------------------------------------