markwon-bundle gradle script
This commit is contained in:
parent
702f2a0546
commit
37ad8effcd
@ -1,4 +1,5 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
apply from: '../markwon-bundle.gradle'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
||||||
@ -26,6 +27,12 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ext.markwon = [
|
||||||
|
'version': '3.0.0-SNAPSHOT',
|
||||||
|
'includeAll': true,
|
||||||
|
'exclude': ['ext-latex', 'core']
|
||||||
|
]
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation project(':markwon-core')
|
implementation project(':markwon-core')
|
||||||
|
@ -85,7 +85,6 @@ ext {
|
|||||||
'junit' : 'junit:junit:4.12',
|
'junit' : 'junit:junit:4.12',
|
||||||
'robolectric': 'org.robolectric:robolectric:3.8',
|
'robolectric': 'org.robolectric:robolectric:3.8',
|
||||||
'ix-java' : 'com.github.akarnokd:ixjava:1.0.0',
|
'ix-java' : 'com.github.akarnokd:ixjava:1.0.0',
|
||||||
'gson' : 'com.google.code.gson:gson:2.8.5',
|
|
||||||
'commons-io' : 'commons-io:commons-io:2.6',
|
'commons-io' : 'commons-io:commons-io:2.6',
|
||||||
'mockito' : 'org.mockito:mockito-core:2.21.0'
|
'mockito' : 'org.mockito:mockito-core:2.21.0'
|
||||||
]
|
]
|
||||||
|
59
markwon-bundle.gradle
Normal file
59
markwon-bundle.gradle
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// await project initialization and check for markwon object then
|
||||||
|
// (so we do not have to force users to put `apply from` block at the bottom
|
||||||
|
// of a build.gradle file)
|
||||||
|
project.afterEvaluate {
|
||||||
|
|
||||||
|
if (!project.hasProperty('markwon')) {
|
||||||
|
throw new RuntimeException("No `markwon` property object is found. " +
|
||||||
|
"Define it with `ext.markwon = [prop: value]`")
|
||||||
|
}
|
||||||
|
|
||||||
|
final def markwon = project.markwon
|
||||||
|
if (!(markwon instanceof Map)) {
|
||||||
|
throw new RuntimeException("`markwon` object property must be of type Map. " +
|
||||||
|
"Groovy short-hand to define: `[:]`.")
|
||||||
|
}
|
||||||
|
|
||||||
|
final def version = markwon.version
|
||||||
|
final def includeAll = markwon.computeIfAbsent('includeAll', { false })
|
||||||
|
final def artifacts
|
||||||
|
if (includeAll) {
|
||||||
|
|
||||||
|
// cannot exclude core
|
||||||
|
final def exclude = markwon.computeIfAbsent('exclude', { [] }) \
|
||||||
|
.unique() \
|
||||||
|
.findAll { 'core' != it }
|
||||||
|
|
||||||
|
artifacts = [
|
||||||
|
'core',
|
||||||
|
'ext-latex',
|
||||||
|
'ext-strikethrough',
|
||||||
|
'ext-tables',
|
||||||
|
'ext-tasklist',
|
||||||
|
'html',
|
||||||
|
'image-gif',
|
||||||
|
'image-okhttp',
|
||||||
|
'image-svg',
|
||||||
|
'recycler',
|
||||||
|
'syntax-highlight'
|
||||||
|
].findAll { !exclude.contains(it) }
|
||||||
|
|
||||||
|
} else {
|
||||||
|
artifacts = (markwon.containsKey('artifacts') ? markwon.artifacts : ['core']).with {
|
||||||
|
// add implicit core artifact
|
||||||
|
if (!it.contains('core')) {
|
||||||
|
it.add('core')
|
||||||
|
}
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!version) {
|
||||||
|
throw new RuntimeException("Please specify version of Markwon, for example: " +
|
||||||
|
"`ext.markwon = [ 'version': '1.0.0']`")
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts.forEach {
|
||||||
|
project.dependencies.add('implementation', "ru.noties.markwon:$it:$version")
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user