generated from JavierSegoviaCordoba/kotlin-template-javiersc
-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
854a65c
commit d9c3dab
Showing
19 changed files
with
172 additions
and
30 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
9 changes: 9 additions & 0 deletions
9
...ject-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/VersionMapper.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,9 @@ | ||
package com.javiersc.semver.project.gradle.plugin | ||
|
||
import com.javiersc.gradle.version.GradleVersion | ||
import java.io.Serializable | ||
|
||
public fun interface VersionMapper : Serializable { | ||
|
||
public fun map(version: GradleVersion): String | ||
} |
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
23 changes: 23 additions & 0 deletions
23
semver-settings-gradle-plugin/api/semver-settings-gradle-plugin.api
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,6 +1,29 @@ | ||
public abstract class com/javiersc/semver/settings/gradle/plugin/SemverSettingsExtension { | ||
public static final field Companion Lcom/javiersc/semver/settings/gradle/plugin/SemverSettingsExtension$Companion; | ||
public static final field ExtensionName Ljava/lang/String; | ||
public fun <init> (Lorg/gradle/api/model/ObjectFactory;)V | ||
public final fun getCommitsMaxCount ()Lorg/gradle/api/provider/Property; | ||
public abstract fun getGitDir ()Lorg/gradle/api/file/RegularFileProperty; | ||
public final fun getTagPrefix ()Lorg/gradle/api/provider/Property; | ||
public final fun isEnabled ()Lorg/gradle/api/provider/Property; | ||
public final fun mapVersion (Lcom/javiersc/semver/project/gradle/plugin/VersionMapper;)V | ||
} | ||
|
||
public final class com/javiersc/semver/settings/gradle/plugin/SemverSettingsExtension$Companion { | ||
} | ||
|
||
public final class com/javiersc/semver/settings/gradle/plugin/SemverSettingsPlugin : org/gradle/api/Plugin { | ||
public fun <init> ()V | ||
public synthetic fun apply (Ljava/lang/Object;)V | ||
public fun apply (Lorg/gradle/api/initialization/Settings;)V | ||
} | ||
|
||
public final class com/javiersc/semver/settings/gradle/plugin/SemverSettingsPlugin$inlined$sam$i$org_gradle_api_Action$0 : org/gradle/api/Action { | ||
public fun <init> (Lkotlin/jvm/functions/Function1;)V | ||
public final synthetic fun execute (Ljava/lang/Object;)V | ||
} | ||
|
||
public final class com/javiersc/semver/settings/gradle/plugin/SemverSettingsPluginKt { | ||
public static final fun semver (Lorg/gradle/api/initialization/Settings;Lorg/gradle/api/Action;)V | ||
} | ||
|
45 changes: 45 additions & 0 deletions
45
...-plugin/main/kotlin/com/javiersc/semver/settings/gradle/plugin/SemverSettingsExtension.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,45 @@ | ||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") | ||
|
||
package com.javiersc.semver.settings.gradle.plugin | ||
|
||
import com.javiersc.semver.project.gradle.plugin.VersionMapper | ||
import com.javiersc.semver.project.gradle.plugin.internal.DefaultTagPrefix | ||
import javax.inject.Inject | ||
import org.gradle.api.file.RegularFileProperty | ||
import org.gradle.api.initialization.Settings | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.provider.Property | ||
import org.gradle.kotlin.dsl.create | ||
import org.gradle.kotlin.dsl.property | ||
|
||
public abstract class SemverSettingsExtension @Inject constructor(objects: ObjectFactory) { | ||
|
||
public val isEnabled: Property<Boolean> = objects.property<Boolean>().convention(true) | ||
|
||
public abstract val gitDir: RegularFileProperty | ||
|
||
public val commitsMaxCount: Property<Int> = objects.property<Int>().convention(-1) | ||
|
||
public val tagPrefix: Property<String> = objects.property<String>().convention(DefaultTagPrefix) | ||
|
||
internal val versionMapper: Property<VersionMapper> = | ||
objects | ||
.property<VersionMapper>() | ||
.convention(VersionMapper { version -> version.toString() }) | ||
|
||
public fun mapVersion(transform: VersionMapper) { | ||
versionMapper.set(transform) | ||
} | ||
|
||
public companion object { | ||
|
||
public const val ExtensionName: String = "semver" | ||
|
||
internal fun register(settings: Settings): SemverSettingsExtension { | ||
val semver = settings.extensions.create<SemverSettingsExtension>(ExtensionName) | ||
val gitDir = settings.providers.provider { settings.rootDir.resolve(".git") } | ||
semver.gitDir.fileProvider(gitDir) | ||
return semver | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...dle-plugin/main/kotlin/com/javiersc/semver/settings/gradle/plugin/SemverSettingsPlugin.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,13 +1,33 @@ | ||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") | ||
|
||
package com.javiersc.semver.settings.gradle.plugin | ||
|
||
import com.javiersc.semver.project.gradle.plugin.SemverExtension | ||
import org.gradle.api.Action | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.initialization.Settings | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
public class SemverSettingsPlugin : Plugin<Settings> { | ||
|
||
override fun apply(target: Settings) { | ||
val semver: SemverSettingsExtension = SemverSettingsExtension.register(target) | ||
target.gradle.beforeProject { project -> | ||
project.pluginManager.apply("com.javiersc.semver") | ||
project.pluginManager.withPlugin("com.javiersc.semver") { | ||
project.configure<SemverExtension> { | ||
this.isEnabled.set(semver.isEnabled) | ||
this.gitDir.set(semver.gitDir) | ||
this.commitsMaxCount.set(semver.commitsMaxCount) | ||
this.tagPrefix.set(semver.tagPrefix) | ||
this.versionMapper.set(semver.versionMapper) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public fun Settings.semver(action: Action<SemverSettingsExtension>) { | ||
action.execute(extensions.getByType()) | ||
} |
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
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...s-gradle-plugin/testFunctional/resources/multi-project-basic/library-one/build.gradle.kts
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,3 @@ | ||
plugins { | ||
java | ||
} |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...s-gradle-plugin/testFunctional/resources/multi-project-basic/library-two/build.gradle.kts
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,3 @@ | ||
plugins { | ||
java | ||
} |
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
...r-settings-gradle-plugin/testFunctional/resources/multi-project-basic/settings.gradle.kts
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,10 @@ | ||
rootProject.name = "multi-project" | ||
|
||
plugins { | ||
id("com.javiersc.semver") | ||
} | ||
|
||
include( | ||
":library-one", | ||
":library-two", | ||
) |
7 changes: 7 additions & 0 deletions
7
semver-settings-gradle-plugin/testFunctional/resources/multi-project/build.gradle.kts
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,7 @@ | ||
plugins { | ||
java | ||
} | ||
|
||
semver { | ||
tagPrefix.set("w") | ||
} |
8 changes: 8 additions & 0 deletions
8
...tings-gradle-plugin/testFunctional/resources/multi-project/library-three/build.gradle.kts
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,8 @@ | ||
plugins { | ||
java | ||
} | ||
|
||
semver { | ||
tagPrefix.set("t") | ||
mapVersion { version -> "12.13.14" } | ||
} |
4 changes: 4 additions & 0 deletions
4
...ettings-gradle-plugin/testFunctional/resources/multi-project/library-two/build.gradle.kts
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,3 +1,7 @@ | ||
plugins { | ||
java | ||
} | ||
|
||
semver { | ||
tagPrefix.set("o") | ||
} |
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