-
Notifications
You must be signed in to change notification settings - Fork 24
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
Showing
73 changed files
with
938 additions
and
986 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2022 Vladimir Raupov | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "ru.ldralighieri.corbind.buildlogic" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
dependencies { | ||
implementation(libs.android.gradlePlugin) | ||
implementation(libs.kotlin.gradlePlugin) | ||
implementation(libs.spotless.gradlePlugin) | ||
implementation(libs.dokka.gradlePlugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("dokka") { | ||
id = "corbind.dokka" | ||
implementationClass = "DokkaConventionPlugin" | ||
} | ||
|
||
register("library") { | ||
id = "corbind.library" | ||
implementationClass = "LibraryConventionPlugin" | ||
} | ||
|
||
register("spotless") { | ||
id = "corbind.spotless" | ||
implementationClass = "SpotlessConventionPlugin" | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
build-logic/convention/src/main/kotlin/DokkaConventionPlugin.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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2022 Vladimir Raupov | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.dokka.gradle.DokkaTask | ||
import java.net.URL | ||
|
||
@Suppress("unused") | ||
class DokkaConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply("org.jetbrains.dokka") | ||
|
||
tasks.withType<DokkaTask>().configureEach { | ||
dokkaSourceSets.named("main") { | ||
jdkVersion.set(JavaVersion.VERSION_11.majorVersion.toInt()) | ||
|
||
skipDeprecated.set(false) | ||
reportUndocumented.set(false) | ||
skipEmptyPackages.set(true) | ||
|
||
sourceLink { | ||
val relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath()) | ||
localDirectory.set(file("src/main/kotlin")) | ||
remoteUrl.set(URL("https://github.com/LDRAlighieri/Corbind/tree/master/$relPath/src/main/kotlin")) | ||
remoteLineSuffix.set("#L") | ||
} | ||
|
||
externalDocumentationLink { | ||
url.set(URL("https://developer.android.com/reference/")) | ||
packageListUrl.set(URL("https://developer.android.com/reference/package-list")) | ||
} | ||
|
||
externalDocumentationLink { | ||
url.set(URL("https://developer.android.com/reference/")) | ||
packageListUrl.set(URL("https://developer.android.com/reference/androidx/package-list")) | ||
} | ||
|
||
externalDocumentationLink { | ||
url.set(URL("https://developer.android.com/reference/")) | ||
packageListUrl.set(URL("https://developer.android.com/reference/com/google/android/material/package-list")) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
build-logic/convention/src/main/kotlin/LibraryConventionPlugin.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2022 Vladimir Raupov | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import com.android.build.gradle.LibraryExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import ru.ldralighieri.corbind.configureKotlinAndroid | ||
|
||
@Suppress("unused") | ||
class LibraryConventionPlugin : Plugin<Project> { | ||
@Suppress("UnstableApiUsage") | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.library") | ||
apply("kotlin-android") | ||
apply("com.vanniktech.maven.publish") | ||
} | ||
|
||
extensions.configure<LibraryExtension> { | ||
configureKotlinAndroid(this) | ||
defaultConfig.targetSdk = findProperty("android.targetSdk").toString().toInt() | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
build-logic/convention/src/main/kotlin/SpotlessConventionPlugin.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2022 Vladimir Raupov | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import com.diffplug.gradle.spotless.SpotlessExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
@Suppress("unused") | ||
class SpotlessConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply("com.diffplug.spotless") | ||
|
||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
extensions.configure<SpotlessExtension> { | ||
kotlin { | ||
target("**/*.kt") | ||
targetExclude("**/build/**/*.kt") | ||
ktlint(libs.findVersion("ktlint").get().toString()) | ||
licenseHeaderFile(rootProject.file("spotless/copyright.kt")) | ||
} | ||
} | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...ogic/convention/src/main/kotlin/ru/ldralighieri/corbind/Project+configureKotlinAndroid.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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2022 Vladimir Raupov | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
@file:Suppress("UnstableApiUsage") | ||
|
||
package ru.ldralighieri.corbind | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.ExtensionAware | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions | ||
|
||
internal fun Project.configureKotlinAndroid( | ||
commonExtension: CommonExtension<*, *, *, *>, | ||
) { | ||
commonExtension.apply { | ||
compileSdk = findProperty("android.compileSdk").toString().toInt() | ||
|
||
defaultConfig { | ||
minSdk = findProperty("android.minSdk").toString().toInt() | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_11.toString() | ||
|
||
// Treat all Kotlin warnings as errors | ||
allWarningsAsErrors = true | ||
|
||
freeCompilerArgs = freeCompilerArgs + listOf( | ||
"-opt-in=kotlinx.coroutines.ObsoleteCoroutinesApi", | ||
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi" | ||
) | ||
} | ||
} | ||
} | ||
|
||
private fun CommonExtension<*, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { | ||
(this as ExtensionAware).extensions.configure("kotlinOptions", block) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2022 Vladimir Raupov | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
@file:Suppress("UnstableApiUsage") | ||
|
||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
include(":convention") |
Oops, something went wrong.