Skip to content

Commit

Permalink
Add GDI
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Dec 2, 2023
1 parent ae82d39 commit 91c70d0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 22 deletions.
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ java {
}

group 'net.neoforged.gradleutils'
version '3.0.0-alpha.5'
version '3.0.0-alpha.6'

repositories {
mavenCentral()
Expand All @@ -31,6 +31,11 @@ if (System.getenv('GPP_KEY')) {
dependencies {
api 'org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r'
api 'io.github.gradle-nexus:publish-plugin:1.3.0'

final gdiVersion = '1.0.13'
api "net.neoforged:groovydslimprover:$gdiVersion"
api "net.neoforged:groovydslimprover:$gdiVersion:base"
api "net.neoforged:groovydslimprover:$gdiVersion:runtime"
}

sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import groovy.transform.NamedVariant
import groovy.transform.PackageScope
import io.github.gradlenexus.publishplugin.NexusPublishExtension
import io.github.gradlenexus.publishplugin.NexusPublishPlugin
import net.minecraftforge.gdi.annotations.DSLProperty
import net.minecraftforge.gdi.annotations.ProjectGetter
import net.neoforged.gradleutils.specs.VersionSpec
import org.gradle.api.Action
import org.gradle.api.Project
Expand Down Expand Up @@ -82,12 +84,15 @@ abstract class GradleUtilsExtension {
shouldSign.convention(project.provider { (System.getenv('GPG_PRIVATE_KEY') || System.getenv('GPG_SUBKEY')) || possibleSecring.getOrNull() })
}

@DSLProperty
abstract DirectoryProperty getGitRoot()

@Nested
@DSLProperty
abstract VersionSpec getVersionSpec()

@Input
@DSLProperty
abstract Property<Boolean> getShouldSign()

Object getVersion() {
Expand Down Expand Up @@ -183,4 +188,7 @@ abstract class GradleUtilsExtension {
this.signAllPublications(project.extensions.getByType(PublishingExtension).publications)
}
}

@ProjectGetter // for the git root property
private Project project() { project }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package net.neoforged.gradleutils.specs

import groovy.transform.CompileStatic
import net.minecraftforge.gdi.annotations.DSLProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.Input
Expand All @@ -22,10 +23,12 @@ abstract class VersionBranchesSpec {
// Whether to suffix the branch to the version, separated with a '-' (hyphen),
// Only suffixed if suffixExemptedBranches does not contains the branch
@Input
@DSLProperty
abstract Property<Boolean> getSuffixBranch();

// Branch names which are exempted from being suffixed (see suffixBranch above)
// Empty string means a situation where the branch cannot be named, for some reason (detached HEAD?)
@Input
@DSLProperty
abstract SetProperty<String> getSuffixExemptedBranches()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package net.neoforged.gradleutils.specs

import groovy.transform.CompileStatic
import net.minecraftforge.gdi.annotations.DSLProperty
import net.neoforged.gradleutils.InternalAccessor
import org.gradle.api.Action
import org.gradle.api.provider.Property
Expand All @@ -16,22 +17,17 @@ import org.gradle.api.tasks.Optional
@CompileStatic
abstract class VersionSpec {
@Nested
@DSLProperty(isConfigurable = true)
abstract VersionBranchesSpec getBranches()

void branches(Action<? extends VersionBranchesSpec> configureAction) {
configureAction.execute(branches)
}

@Nested
@DSLProperty(isConfigurable = true)
abstract VersionTagsSpec getTags()

void tags(Action<? extends VersionTagsSpec> configureAction) {
configureAction.execute(tags)
}

// Prefixed to version, separated with a '-' (hyphen)
@Input
@Optional
@DSLProperty
abstract Property<String> getVersionPrefix();

// Specific to NeoForge; sets the version prefix to the Minecraft version and adds exempted branches for the MC version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package net.neoforged.gradleutils.specs

import groovy.transform.CompileStatic
import net.minecraftforge.gdi.annotations.DSLProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.Input
Expand All @@ -20,42 +21,45 @@ abstract class VersionTagsSpec {
stripTagLabel.convention(true)
}

// Whether to append the the commit count to the version (pre-labeling)
/** Whether to append the the commit count to the version (pre-labeling) */
@Input
@DSLProperty
abstract Property<Boolean> getAppendCommitOffset()

// Label, which is appended to version separated with a '-'. Can be overriden by extracted label and custom logic
/** Label, which is appended to version separated with a '-'. Can be overriden by extracted label and custom logic */
@Input
@Optional
@DSLProperty
abstract Property<String> getLabel()

// Whether or not to extract the label from the tag; overrides the label set above, can be overriden by custom logic
/** Whether or not to extract the label from the tag; overrides the label set above, can be overriden by custom logic */
@Input
@DSLProperty
abstract Property<Boolean> getExtractLabel()

// If this label is present on a tag, clear the label for the version and skip that tag (find the next one)
/** If this label is present on a tag, clear the label for the version and skip that tag (find the next one) */
@Input
@Optional
@DSLProperty
abstract Property<String> getCleanMarkerLabel()

// Whether to strip the label from the tag if present at the end (separated by '-') in the final version
/** Whether to strip the label from the tag if present at the end (separated by '-') in the final version */
@Input
@DSLProperty
abstract Property<Boolean> getStripTagLabel()

// Whether to look for lightweight tags
/** Whether to look for lightweight tags */
@Input
@DSLProperty
abstract Property<Boolean> getIncludeLightweightTags()

// (Glob) filters to match against the tag
/** (Glob) filters to match against the tag */
@Input
@DSLProperty
abstract SetProperty<String> getIncludeFilters()

// Includes a prefix (a filter which matches anything that has certain characters before it)
/** Includes a prefix (a filter which matches anything that has certain characters before it) */
void includePrefix(String prefix) {
includeFilter(prefix + '**')
}

void includeFilter(String filter) {
includeFilters.add(filter)
includeFilters.add(prefix + '**')
}
}

0 comments on commit 91c70d0

Please sign in to comment.