generated from cortinico/kotlin-gradle-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow creating extensions in packages
- Loading branch information
Showing
6 changed files
with
72 additions
and
80 deletions.
There are no files selected for viewing
6 changes: 2 additions & 4 deletions
6
src/main/kotlin/app/revanced/patches/gradle/ExtensionExtension.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,11 @@ | ||
package app.revanced.patches.gradle | ||
|
||
import org.gradle.api.provider.Property | ||
|
||
abstract class ExtensionExtension { | ||
open class ExtensionExtension { | ||
/** | ||
* The name of the extension. | ||
* | ||
* The name is the full resource path of the extension in the final patches file. | ||
* Example: `extensions/extension.rve`. | ||
*/ | ||
abstract val name: Property<String> | ||
var name: String? = null | ||
} |
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
42 changes: 14 additions & 28 deletions
42
src/main/kotlin/app/revanced/patches/gradle/PatchesExtension.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,50 +1,36 @@ | ||
package app.revanced.patches.gradle | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.provider.Property | ||
import javax.inject.Inject | ||
|
||
@Suppress("unused") | ||
abstract class PatchesExtension @Inject constructor(objectFactory: ObjectFactory) { | ||
open class PatchesExtension { | ||
/** | ||
* The path to the extensions project relative to the root project. | ||
* | ||
* Used by the patches plugin to consume the extension artifacts. | ||
* | ||
* Defaults to `:extensions`. | ||
*/ | ||
abstract val extensionsProjectPath: Property<String> | ||
var extensionsProjectPath: String? = ":extensions" | ||
|
||
internal val about = objectFactory.newInstance(About::class.java) | ||
/** | ||
* About information for the project. | ||
*/ | ||
val about = About() | ||
|
||
fun about(block: About.() -> Unit) { | ||
about.block() | ||
} | ||
|
||
init { | ||
extensionsProjectPath.convention(":extensions") | ||
} | ||
|
||
/** | ||
* About information for the project. | ||
* | ||
* Used by the patches plugin to create the manifest file and set up the publication of the patches project. | ||
*/ | ||
abstract class About @Inject constructor(project: Project) { | ||
abstract val name: Property<String> | ||
abstract val description: Property<String> | ||
abstract val source: Property<String> | ||
abstract val author: Property<String> | ||
abstract val contact: Property<String> | ||
abstract val website: Property<String> | ||
abstract val license: Property<String> | ||
internal abstract val version: Property<String> | ||
internal abstract val timestamp: Property<Long> | ||
|
||
init { | ||
version.convention(project.version.toString()) | ||
timestamp.convention(System.currentTimeMillis()) | ||
} | ||
class About { | ||
var name: String? = null | ||
var description: String? = null | ||
var source: String? = null | ||
var author: String? = null | ||
var contact: String? = null | ||
var website: String? = null | ||
var license: String? = null | ||
} | ||
} |
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
37 changes: 15 additions & 22 deletions
37
src/main/kotlin/app/revanced/patches/gradle/SettingsExtension.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,30 +1,23 @@ | ||
package app.revanced.patches.gradle | ||
|
||
import org.gradle.api.provider.Property | ||
|
||
abstract class SettingsExtension { | ||
open class SettingsExtension { | ||
/** | ||
* The path to the patches project relative to the root project. | ||
* | ||
* Used by the settings plugin to include the patches project | ||
* and apply the patches plugin to the patches project. | ||
* | ||
* Defaults to `patches`. | ||
* The path to the patches project. | ||
*/ | ||
abstract val patchesProjectPath: Property<String> | ||
var patchesProjectPath = "patches" | ||
|
||
/** | ||
* The path to the extensions project relative to the root project. | ||
* | ||
* Used by the settings plugin to include the extensions project | ||
* and apply the extensions plugin to the extensions project. | ||
* | ||
* Defaults to `extensions`. | ||
*/ | ||
abstract val extensionsProjectPath: Property<String> | ||
// Need to rename, otherwise it will conflict with the `getExtensions` property from ExtensionAware. | ||
@get:JvmName("getExtensionsExtension") | ||
val extensions = ExtensionsExtension() | ||
|
||
fun extensions(block: ExtensionsExtension.() -> Unit) { | ||
ExtensionsExtension().apply(block) | ||
} | ||
|
||
init { | ||
patchesProjectPath.convention("patches") | ||
extensionsProjectPath.convention("extensions") | ||
class ExtensionsExtension { | ||
/** | ||
* The path to the project containing the extension projects. | ||
*/ | ||
var projectPath: String? = "extensions" | ||
} | ||
} |
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