-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2830e7
commit 3ecf655
Showing
4 changed files
with
47 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 5 additions & 48 deletions
53
plugin/src/main/kotlin/com/toolkit/plugin/util/_requireEnv.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,14 @@ | ||
package com.toolkit.plugin.util | ||
|
||
import com.toolkit.plugin.androidLibrary | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.javadoc.Javadoc | ||
import org.gradle.jvm.tasks.Jar | ||
import org.jetbrains.kotlin.konan.file.File | ||
|
||
internal fun Project.missing(vararg name: String): Boolean { | ||
return name.map(::containsEnv).any { | ||
if (it.not()) { | ||
println("Missing Variable: $it") | ||
true | ||
} else { | ||
false | ||
} | ||
} | ||
} | ||
internal fun Project.missing(vararg name: String) = | ||
name.map(::containsEnv).any { it.not() } | ||
|
||
internal fun Project.containsEnv(name: String): Boolean { | ||
val env = System.getenv("name") ?: (properties[name] as? String) | ||
return env.isNullOrBlank().not() | ||
} | ||
|
||
private fun Project.setupJavadoc(): Jar { | ||
configurations.maybeCreate("jacocoDeps") | ||
|
||
val javadoc = tasks.register("javadoc", Javadoc::class.java) { | ||
val list = ArrayList<java.io.File>() | ||
androidLibrary.sourceSets.forEach { set -> list.addAll(set.java.srcDirs) } | ||
|
||
it.isFailOnError = false | ||
it.setExcludes(listOf("**/*.kt", "**/*.java")) | ||
it.source(list) | ||
it.classpath += files(androidLibrary.bootClasspath.joinToString(separator = File.separator)) | ||
it.classpath += configurations.named("jacocoDeps").get() | ||
}.get() | ||
|
||
return tasks.register("javadocJar", Jar::class.java) { | ||
it.dependsOn(javadoc) | ||
it.archiveClassifier.set("javadoc") | ||
it.from(javadoc.destinationDir) | ||
}.get() | ||
} | ||
|
||
private fun Project.setupSources() = tasks.register("sourcesJar", Jar::class.java) { | ||
val mainSource = androidLibrary.sourceSets.named("main").get().java.srcDirs | ||
it.from(mainSource) | ||
it.archiveClassifier.set("sources") | ||
}.get() | ||
|
||
private fun Project.setupArtifacts(javadoc: Jar, sources: Jar) { | ||
artifacts { | ||
it.add("archives", javadoc) | ||
it.add("archives", sources) | ||
if (env.isNullOrBlank()) { | ||
println("Missing Variable: $name") | ||
} | ||
return env.isNullOrBlank().not() | ||
} |