Skip to content

Commit

Permalink
Add library publishing and update Gradle/Kotlin versions
Browse files Browse the repository at this point in the history
  • Loading branch information
cypherdare committed Mar 13, 2022
1 parent 8698734 commit eca09a8
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ Optional parameters:
* `-f` to force overwrite target `_nonstop.svg` file,
* `-v` to have verbose output.
## Using as a Java/Kotlin dependency
From version 1.1.2, SVG non-stop is available via [JitPack](https://jitpack.io/#14v/svg-non-stop) as a library:
```groovy
repositories {
// ...
maven { url 'https://jitpack.io' }
}
dependencies {
implementation "com.github.14v:svg-non-stop:$version"
}
```

Use `NonStop.process(rootNodes)` with the root [NodeList](https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/NodeList.html)
of the SVG file. See the source of the `main()` function for an example.

## Technical notes
Utility copies stops definitions into target gradients in SVG file. Then IDE can process file correctly. Utility is _not_ for use in android code.

Expand Down
38 changes: 33 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
plugins {
kotlin("jvm") version "1.3.61"
kotlin("jvm") version "1.6.10"
application
`java-library`
`maven-publish`
}

group = ""
version = "1.1.1"
group = "com.github.14v"
version = "1.1.2"

application {
mainClassName = "NonStopKt"
mainClass.set("NonStopKt")
}

repositories {
Expand All @@ -25,4 +27,30 @@ tasks {
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
}
}

java {
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])

pom {
name.set("svg-non-stop")
url.set("https://github.com/14v/svg-non-stop")
licenses {
license {
name.set("MIT License")
url.set("https://github.com/14v/svg-non-stop/blob/master/LICENSE")
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 12 additions & 0 deletions src/main/kotlin/NonStop.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ import javax.xml.transform.TransformerFactory
import javax.xml.transform.dom.DOMSource
import javax.xml.transform.stream.StreamResult

/**
* Utility for repairing SVG for compatibility with Android build tools vector drawable
* conversion.
*/
object NonStop {

/**
* Whether to log verbosely when processing.
*/
var optionVerbose = false

/**
* Modifies the given XML [rootNodes] to repair missing stop info so the SVG can be
* converted to an Android vector asset by the Android build tools.
* @return whether any changes were made.
*/
fun processSvg(rootNodes: NodeList): Boolean {
val defsNode = rootNodes.findNode("defs")
if (defsNode == null) {
Expand Down

0 comments on commit eca09a8

Please sign in to comment.