Skip to content

Commit

Permalink
Fixed the Gradle artifacts (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanisidrowu authored Oct 20, 2020
1 parent d441c31 commit cf4de73
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,19 @@ Then, add this dependency to the `build.gradle` file in app directory.

```gradle
dependencies {
implementation "com.github.ivanisidrowu:KtRssReader:v2.0.0"
implementation "com.github.ivanisidrowu.KtRssReader:ktRssReader:v2.0.0"
}
```

If you want to customize data format, you have to add these dependencies.

```gradle
apply plugin: 'kotlin-kapt'
dependencies {
implementation "com.github.ivanisidrowu.KtRssReader:ktRssReader:v2.0.0"
implementation "com.github.ivanisidrowu.KtRssReader:annotation:v2.0.0"
kapt "com.github.ivanisidrowu.KtRssReader:processor:v2.0.0"
}
```

Expand Down
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -45,6 +46,25 @@ allprojects {
}
}

subprojects { project ->
if (project.name == 'annotation' || project.name == 'processor') {
apply plugin: 'java'
apply plugin: 'maven'

sourceCompatibility = 1.8 // java 8
targetCompatibility = 1.8

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives sourcesJar
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
3 changes: 3 additions & 0 deletions ktRssReader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.github.dcendents.android-maven'

group='com.github.ivanisidrowu'

android {
compileSdkVersion 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ class ParserGenerator(

funSpec.addStatement("\nreturn $outputClassName(")
// Generate constructor statements
propertyToParseData.forEach { generateConstructor(it, funSpec) }
var index = 0
propertyToParseData.forEach {
generateConstructor(it, funSpec, index == propertyToParseData.size - 1)
index ++
}

funSpec.addStatement("$TAB)")
return funSpec.build()
Expand Down Expand Up @@ -343,7 +347,8 @@ class ParserGenerator(

private fun generateConstructor(
parseData: Map.Entry<String, ParseData>,
funSpec: FunSpec.Builder
funSpec: FunSpec.Builder,
isLastLine: Boolean
) {
val stringBuilder = StringBuilder()
val dataType = parseData.value.dataType
Expand Down Expand Up @@ -377,7 +382,12 @@ class ParserGenerator(
}
}
}
funSpec.addStatement("$TAB$TAB${parseData.key} = $stringBuilder,")

if (isLastLine) {
funSpec.addStatement("$TAB$TAB${parseData.key} = $stringBuilder")
} else {
funSpec.addStatement("$TAB$TAB${parseData.key} = $stringBuilder,")
}
}

private fun getTagCandidates(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ReaderGenerator(
.addParameter(configParameter.build())
.addModifiers(KModifier.INLINE)
.addCode(
"return %T.read<%T>(url = $URL, customParser = { xml -> %T.parse(xml) }, $CONFIG)",
"return %T.read<%T>(url = $URL, customParser = { xml -> %T.parse(xml) }, config = $CONFIG)",
readerClassName,
outputClassName,
parserClassName
Expand All @@ -85,7 +85,7 @@ class ReaderGenerator(
)
.addModifiers(KModifier.INLINE)
.addStatement(
"return %T.flowRead<%T>(url = $URL, customParser = { xml -> %T.parse(xml) }, $CONFIG)",
"return %T.flowRead<%T>(url = $URL, customParser = { xml -> %T.parse(xml) }, config = $CONFIG)",
readerClassName,
outputClassName,
parserClassName
Expand All @@ -104,7 +104,7 @@ class ReaderGenerator(
)
.addModifiers(KModifier.INLINE, KModifier.SUSPEND)
.addStatement(
"return %T.coRead<%T>(url = $URL, customParser = { xml -> %T.parse(xml) }, $CONFIG)",
"return %T.coRead<%T>(url = $URL, customParser = { xml -> %T.parse(xml) }, config = $CONFIG)",
readerClassName,
outputClassName,
parserClassName
Expand Down

0 comments on commit cf4de73

Please sign in to comment.