Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support bundling CLI and minor updates #22

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e90783d
Add GHA config
Goooler Feb 20, 2024
00c2168
Fix IconWriter param
Goooler Feb 20, 2024
0677f3c
Add renovate.json
renovate[bot] Feb 20, 2024
a9a14f8
Group AGP updates
Goooler Feb 20, 2024
6d3814e
Update AGP to v27.2.2
renovate[bot] Feb 20, 2024
bd1e2df
Update dependency gradle to v8
renovate[bot] Feb 20, 2024
4f5c5b7
Update plugin org.jetbrains.kotlin.jvm to v1.9.22
renovate[bot] Feb 20, 2024
73d44ef
Use toolchain
Goooler Feb 20, 2024
65ac31b
Update dependency com.google.guava:guava to v23.6.1-jre
renovate[bot] Feb 20, 2024
dff9177
Update dependency com.squareup:kotlinpoet to v1.16.0
renovate[bot] Feb 20, 2024
7733414
Update dependency com.google.guava:guava to v33
renovate[bot] Feb 20, 2024
b101c2d
Update AGP to v31
renovate[bot] Feb 20, 2024
3e1ef66
Fix Svg2Vector.parseSvgToXml
Goooler Feb 20, 2024
790ecae
Bump JDK usages
Goooler Feb 20, 2024
f7a95e9
Tweaks
Goooler Feb 20, 2024
223e713
Update wrapper files
Goooler Feb 20, 2024
537ded8
Revert useJUnitPlatform
Goooler Feb 20, 2024
70bae33
Update AGP to v31.3.0
renovate[bot] Feb 29, 2024
a903761
Update plugin org.jetbrains.kotlin.jvm to v1.9.23
renovate[bot] Mar 7, 2024
20f2b2b
Update dependency gradle to v8.7
renovate[bot] Mar 22, 2024
cbbd85e
Update AGP to v31.3.1
renovate[bot] Mar 18, 2024
3f24b27
Update dependency com.google.guava:guava to v33.1.0-jre
renovate[bot] Mar 27, 2024
ccb6049
Update AGP to v31.3.2
renovate[bot] Apr 10, 2024
704cfe9
Update dependency com.google.guava:guava to v33.2.0-jre
renovate[bot] May 2, 2024
bf9bdd9
Update dependency gradle to v8.8
renovate[bot] May 31, 2024
cd8e9e8
Update dependency com.google.guava:guava to v33.2.1-jre
renovate[bot] May 31, 2024
b055d0b
Update dependency com.squareup:kotlinpoet to v1.18.0
renovate[bot] Jul 9, 2024
1807e09
Update AGP to v31.5.1
renovate[bot] Jul 11, 2024
630e610
Update dependency gradle to v8.9
renovate[bot] Jul 11, 2024
82f8513
Update plugin org.jetbrains.kotlin.jvm to v2
renovate[bot] May 21, 2024
a9a77ff
Update dependency com.squareup:kotlinpoet to v1.18.1
renovate[bot] Jul 19, 2024
6a61cbd
Support bundling CLI
Goooler Jul 20, 2024
01e83ab
Update gradle/actions action to v4
renovate[bot] Aug 4, 2024
316f8d8
Update dependency com.android.tools:r8 to v8.3.37
renovate[bot] Jul 20, 2024
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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build

on:
pull_request:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- run: ./gradlew build
- uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest'
with:
name: svg2compose-binary
path: build/libs/svg2compose-*-binary.jar
if-no-files-found: error
131 changes: 117 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.5.21"
kotlin("jvm") version "2.0.0"
id("com.github.gmazzo.buildconfig") version "5.4.0"
id("maven-publish")
}

group = "br.com.devsrsouza"
version = "0.7.0"
description = "Converts SVG or Android Vector Drawable to Compose code."
val baseName = "svg2compose"

repositories {
mavenCentral()
maven("https://maven.google.com")
maven("https://jetbrains.bintray.com/trove4j")
}
val r8: Configuration by configurations.creating

dependencies {
implementation("com.google.guava:guava:23.0")
implementation("com.android.tools:sdk-common:27.2.0-alpha16")
implementation("com.android.tools:common:27.2.0-alpha16")
implementation("com.squareup:kotlinpoet:1.9.0")
implementation("com.google.guava:guava:33.2.1-jre")
implementation("com.android.tools:sdk-common:31.5.1")
implementation("com.android.tools:common:31.5.1")
implementation("com.squareup:kotlinpoet:1.18.1")
implementation("org.ogce:xpp3:1.1.6")
implementation("com.github.ajalt.clikt:clikt:4.4.0")

testImplementation(kotlin("test-junit"))

r8("com.android.tools:r8:8.3.37")
}

tasks.test {
useJUnit()
}

tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "1.8"
java {
toolchain.languageVersion = JavaLanguageVersion.of(11)
Comment on lines -31 to +32
Copy link
Author

Choose a reason for hiding this comment

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

com.android.tools requires Java 11 or newer.

}

buildConfig {
buildConfigField("VERSION_NAME", version.toString())
buildConfigField("DESCRIPTION", description)
packageName = "br.com.devsrsouza.svg2compose"
}

publishing {
Expand All @@ -39,3 +45,100 @@ publishing {
}
}
}

tasks.withType<Jar>().configureEach {
archiveBaseName = baseName
archiveVersion = version.toString()

manifest {
attributes["Main-Class"] = "br.com.devsrsouza.svg2compose.MainKt"
attributes["Implementation-Version"] = version.toString()
}
}

val fatJar by tasks.registering(Jar::class) {
dependsOn(configurations.runtimeClasspath)
dependsOn(tasks.jar)

from(sourceSets.main.map { it.output.classesDirs + it.output.resourcesDir })
from(configurations.runtimeClasspath.map { it.asFileTree.files.map(::zipTree) })

archiveClassifier = "fat"

duplicatesStrategy = DuplicatesStrategy.EXCLUDE

exclude(
"**/*.kotlin_metadata",
"**/*.kotlin_builtins",
"**/*.kotlin_module",
"**/module-info.class",
"assets/**",
"font_metrics.properties",
"META-INF/AL2.0",
"META-INF/DEPENDENCIES",
"META-INF/jdom-info.xml",
"META-INF/LGPL2.1",
"META-INF/maven/**",
"META-INF/native-image/**",
"META-INF/proguard/**",
"META-INF/*.version",
"META-INF/*.SF",
"META-INF/*.DSA",
"META-INF/*.RSA",
"**/*.proto",
"**/*.dex",
"**/LICENSE**",
"**/NOTICE**",
"r8-version.properties",
"migrateToAndroidx/*",
"xsd/catalog.xml",
)
}

val r8File = layout.buildDirectory.file("libs/$baseName-$version-r8.jar").map { it.asFile }
val rulesFile = project.file("src/main/proguard-rules.pro")
val r8Jar by tasks.registering(JavaExec::class) {
dependsOn(fatJar)

val fatJarFile = fatJar.get().archiveFile
inputs.file(fatJarFile)
inputs.file(rulesFile)
outputs.file(r8File)

classpath(r8)
mainClass = "com.android.tools.r8.R8"
args(
"--release",
"--classfile",
"--output", r8File.get().path,
"--pg-conf", rulesFile.path,
"--lib", System.getProperty("java.home"),
fatJarFile.get().toString(),
)
}

val binaryFile = layout.buildDirectory.file("libs/$baseName-$version-binary.jar").map { it.asFile }
val binaryJar by tasks.registering(Task::class) {
dependsOn(r8Jar)

val r8FileProvider = layout.file(r8File)
val binaryFileProvider = layout.file(binaryFile)
inputs.files(r8FileProvider)
outputs.file(binaryFileProvider)

doLast {
val r8File = r8FileProvider.get().asFile
val binaryFile = binaryFileProvider.get().asFile

binaryFile.parentFile.mkdirs()
binaryFile.delete()
binaryFile.writeText("#!/bin/sh\n\nexec java \$JAVA_OPTS -jar \$0 \"\$@\"\n\n")
binaryFile.appendBytes(r8File.readBytes())

binaryFile.setExecutable(true, false)
}
}

tasks.assemble {
dependsOn(binaryJar)
}
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
kotlin.code.style=official

org.gradle.caching=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8
org.gradle.parallel=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading