Skip to content

Commit

Permalink
Merge pull request #5 from jmfayard/development
Browse files Browse the repository at this point in the history
Release v0.2.4
  • Loading branch information
jmfayard authored Oct 16, 2018
2 parents 0cc821f + bd1bf6b commit 950b930
Show file tree
Hide file tree
Showing 15 changed files with 2,137 additions and 27 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

# 0.2.4

- #4 SyncLibs generate wrong output file
- #1 Make it slightly easier to manually update the version
- #3 Add buildSrc/.gitignore



# 0.2.3

- Change folder to `buildSrc/src/main/kotlin` see [separate language source files](https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:separate_language_source_files)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Step1: Edit build.gradle(.kts)
```groovy
plugins {
// https://plugins.gradle.org/plugin/jmfayard.github.io.gradle-kotlin-dsl-libs
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.3"
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.4"
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "jmfayard.github.io"
version = "0.2.3"
version = "0.2.4"

gradlePlugin {
plugins {
Expand Down
66 changes: 45 additions & 21 deletions src/main/kotlin/jmfayard/github/io/KotlinPoetry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ internal val VersionsClassName = "Versions"
val MEANING_LESS_NAMES: List<String> = listOf(
"common", "core", "core-testing", "testing", "runtime", "extensions",
"compiler", "migration", "db", "rules", "runner", "monitor", "loader",
"media", "print", "io", "media", "collection"
"media", "print", "io", "media", "collection", "gradle"
)

val GITIGNORE = """
.gradle/
build/
"""

val GRADLE_KDOC = """
To update Gradle, edit the wrapper file at path:
./gradle/wrapper/gradle-wrapper.properties
"""

val GENERATED_BY_SYNCLIBS = """
Generated by [gradle-kotlin-dsl-libs](https://github.com/jmfayard/gradle-kotlin-dsl-libs)
Expand Down Expand Up @@ -99,6 +109,7 @@ fun kotlinpoet(versions: List<Dependency>, gradleConfig: GradleConfig): KotlinPo

val Gradle: TypeSpec = TypeSpec.objectBuilder("Gradle")
.addProperties(gradleProperties)
.addKdoc(GRADLE_KDOC)
.build()

val Versions: TypeSpec = TypeSpec.objectBuilder("Versions")
Expand Down Expand Up @@ -127,24 +138,29 @@ fun kotlinpoet(versions: List<Dependency>, gradleConfig: GradleConfig): KotlinPo


fun SyncLibsTask.Companion.parseGraph(graph: DependencyGraph): List<Dependency> {
val versions = graph.current + graph.exceeded + graph.outdated
val dependencies: List<Dependency> = graph.current + graph.exceeded + graph.outdated + graph.unresolved

val map = mutableMapOf<String, Dependency>()
for (v in versions) {
val key = escapeName(v.name)
val fdqnName = escapeName("${v.group}_${v.name}")
for (d: Dependency in dependencies) {
val key = escapeName(d.name)
val fdqnName = escapeName("${d.group}_${d.name}")


if (key in MEANING_LESS_NAMES) {
v.escapedName = fdqnName
d.escapedName = fdqnName
} else if (map.containsKey(key)) {
v.escapedName = fdqnName
map[key]!!.escapedName = fdqnName
d.escapedName = fdqnName

// also use FDQN for the dependency that conflicts with this one
val other = map[key]!!
other.escapedName = escapeName("${other.group}_${other.name}")
println("Will use FDQN for ${other.escapedName}")
} else {
map[key] = v
v.escapedName = key
map[key] = d
d.escapedName = key
}
}
return versions
return dependencies
.distinctBy { it.escapedName }
.sortedBy { it.escapedName }

Expand Down Expand Up @@ -173,21 +189,29 @@ fun escapeName(name: String): String {
}
}

fun Dependency.versionInformation(): String = when {
latest.isNullOrBlank().not() -> "// exceed the version found: $latest"
reason != null && reason.isNotBlank() -> {
val shorterReason = reason.lines().take(4).joinToString(separator = "\n")
"\n/* error: $shorterReason \n.... */"
fun Dependency.versionInformation(): String {
return when {
latest.isNullOrBlank().not() -> "// exceed the version found: $latest"
reason.isNullOrBlank().not() -> this.unresolvedReason()!!
available != null -> available.displayComment()
else -> "// up-to-date"
}
available != null -> available.displayComment()
else -> "// up-to-date"
}


fun Dependency.unresolvedReason() : String? {
val shorterReason = reason?.lines()?.take(4)?.joinToString(separator = "\n") ?: ""
return when {
shorterReason.isBlank() -> ""
shorterReason.contains("Could not find any matches") -> "// No update information. Is this dependency available on jcenter or mavenCentral?"
else -> "\n/* $shorterReason \n.... */"
}
}

fun AvailableDependency.displayComment(): String = when {
release.isNullOrBlank().not() -> "// available: release=$release"
milestone.isNullOrBlank().not() -> "// available: milestone=$milestone"
integration.isNullOrBlank().not() -> "// available: integration=$integration"
release.isNullOrBlank().not() -> """// available release: "$release" """
milestone.isNullOrBlank().not() -> """// available milestone: "$milestone" """
integration.isNullOrBlank().not() -> """// available integration: "$integration" """
else -> "// " + this.toString()
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/jmfayard/github/io/SyncLibsTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ open class SyncLibsTask : DefaultTask() {
println("Creating empty ${settingsGradleKts.absolutePath}")
settingsGradleKts.writeText("")
}

val gitIgnore = project.file("buildSrc/.gitignore")
if (gitIgnore.exists().not()) {
gitIgnore.writeText(GITIGNORE)
}
}

}
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/jmfayard/github/io/NonRegression.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ fun nonRegressionForFile(json: File, nonregFile: File) {
$missingNames""".trimIndent()
) else {
println("Non-regression ok")
nonregFile.writeText(escapedNames.joinToStringWithNewLines())
}
} else {
nonregFile.writeText(escapedNames.joinToStringWithNewLines())
Expand Down
133 changes: 133 additions & 0 deletions src/test/resources/names/Catchup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
aapt2
adapter_rxjava2
androidx_annotation_annotation
androidx_core_core
annotations
apollo_android_support
apollo_gradle_plugin
apollo_http_cache
apollo_runtime
apollo_rx2_support
appcompat
auto_common
auto_service
autodispose
autodispose_android
autodispose_android_archcomponents
autodispose_android_archcomponents_ktx
autodispose_android_ktx
autodispose_ktx
autodispose_lifecycle
autodispose_lifecycle_ktx
browser
bugsnag_android
bugsnag_android_gradle_plugin
com_android_tools_build_gradle
com_github_bumptech_glide_compiler
com_gradle_build_scan_gradle_plugin
com_tickaroo_tikxml_annotation
com_tickaroo_tikxml_core
constraintlayout
converter_htmlescape
converter_moshi
core_ktx
crumb_annotations
crumb_compiler
crumb_compiler_api
dagger
dagger_android
dagger_android_processor
dagger_android_support
dagger_compiler
dagger_spi
drawerlayout
emoji
emoji_appcompat
error_prone_annotations
firebase_config
firebase_core
firebase_database
firebase_perf
firebase_plugins
flick
flipper
fragment
fragment_ktx
gesture_views
glide
inboxrecyclerview
inspector
inspector_android_compiler_extension
inspector_autovalue_compiler_extension
inspector_compiler
inspector_factory_compiler
inspector_factory_compiler_annotations
inspector_nullability_compiler_extension
javapoet
javax_annotation
jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin
jsoup
jsr305
junit
kotlin_annotation_processing_gradle
kotlin_gradle_plugin
kotlin_metadata
kotlin_noarg
kotlin_scripting_compiler_embeddable
kotlin_stdlib
kotlin_stdlib_jdk7
kotlin_stdlib_jdk8
kotlinpoet
lazythreetenbp
leakcanary_android
leakcanary_android_no_op
library
library_no_op
lifecycle_compiler
lifecycle_extensions
lint_gradle
logging_interceptor
lottie
madge
material
moshi
moshi_kotlin_codegen
moshi_lazy_adapters
okhttp
okhttp3_integration
okio
palette
palette_ktx
play_publisher
preference
preference_ktx
process_phoenix
processor
psync
recyclerview_animators
recyclerview_integration
retrofit
retrofit_converter
retrofit_mock
room_compiler
room_runtime
room_rxjava2
rx_preferences
rxandroid
rxbinding_design_kotlin
rxbinding_kotlin
rxbinding_support_v4_kotlin
rxjava
rxrelay
scalpel
stetho
stetho_okhttp3
stetho_timber
support_annotations
swiperefreshlayout
taptargetview
telescope
timber
truth
unbescape
viewpager
2 changes: 2 additions & 0 deletions src/test/resources/names/FastHub.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ cardview_v7
colorpicker_library
com_android_support_test_rules
com_android_support_test_runner
com_android_tools_build_gradle
com_github_b3er_rxfirebase_firebase_database
com_google_firebase_firebase_database
commonmark
commonmark_ext_autolink
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/names/KotlinAcademyApp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ activitystarter_kotlin
anko_coroutines
appcompat_v7
codeview
com_android_tools_build_gradle
com_google_android_support_wearable
com_google_android_wearable_wearable
controlsfx
converter_gson
Expand Down Expand Up @@ -46,6 +48,7 @@ kotlin_test_junit
kotlinandroidviewbindings
kotlinx_coroutines_core
kotlinx_coroutines_core_js
kotlinx_coroutines_core_native
kotlinx_coroutines_javafx
kotlinx_gradle_serialization_plugin
kotlinx_html_js
Expand All @@ -72,4 +75,5 @@ squash
squash_h2
squash_postgres
tornadofx
traynotification
wear
4 changes: 2 additions & 2 deletions src/test/resources/names/android-sunflower.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
aapt2
appcompat
com_android_tools_build_gradle
com_diffplug_gradle_spotless_gradle_plugin
com_github_bumptech_glide_compiler
constraintlayout
Expand All @@ -13,7 +14,6 @@ espresso_contrib
espresso_core
espresso_intents
glide
gradle
gson
jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin
junit
Expand All @@ -32,4 +32,4 @@ recyclerview
room_compiler
room_runtime
uiautomator
work_runtime_ktx
work_runtime_ktx
2 changes: 1 addition & 1 deletion src/test/resources/names/koin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ appcompat_v7
asciidoctor_gradle_plugin
asciidoctorj_pdf
com_android_support_test_runner
com_android_tools_build_gradle
constraint_layout
converter_gson
core_testing
design
dokka_android_gradle_plugin
gradle
gradle_bintray_plugin
gson
httpclient
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/names/material-dialogs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ annotation
appcompat
assent
bintray_release
gradle
com_android_tools_build_gradle
gradle_versions_plugin
gridlayout
jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin
Expand Down
Loading

0 comments on commit 950b930

Please sign in to comment.