Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GroovyDSLImprover #25

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'org.parchmentmc.writtenbooks' version '0.+'
id 'java-gradle-plugin'
id 'maven-publish'
id 'groovy'
}

project.group = 'org.parchmentmc'
Expand All @@ -14,6 +15,10 @@ repositories {
maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
metadataSources {
mavenPom()
gradleMetadata()
Comment on lines +19 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this? (There should be a comment here about it.)

}
}
gradlePluginPortal()
mavenCentral()
Expand All @@ -27,6 +32,9 @@ dependencies {
implementation 'org.parchmentmc.feather:io-moshi:1.0.0.3'
implementation 'com.google.guava:guava:31.1-jre'

compileOnly 'net.minecraftforge:groovydslimprover:1.0.4'
implementation 'net.minecraftforge:groovydslimprover:1.0.4:runtime'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
Expand All @@ -43,7 +51,7 @@ java {

gradlePlugin {
// Define the plugin
plugins.register("compass") {
plugins.register('compass') {
id = 'org.parchmentmc.compass'
implementationClass = 'org.parchmentmc.compass.CompassPlugin'
}
Expand All @@ -61,3 +69,8 @@ publishing {
tasks.named('wrapper', Wrapper) {
distributionType = Wrapper.DistributionType.ALL
}

tasks.withType(GroovyCompile).configureEach {
it.options.incremental = true
it.groovyOptions.optimizationOptions(['indy': true])
}
53 changes: 53 additions & 0 deletions src/main/groovy/org/parchmentmc/compass/CompassExtension.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.parchmentmc.compass

import groovy.transform.CompileStatic
import net.minecraftforge.gdi.annotations.DSLProperty
import net.minecraftforge.gdi.annotations.ProjectGetter
import org.gradle.api.Project
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.parchmentmc.compass.storage.io.MappingIOFormat

import javax.inject.Inject

@CompileStatic
abstract class CompassExtension {
private final Project project

@Inject
CompassExtension(final Project project) {
this.project = project
getLauncherManifestURL().convention('https://piston-meta.mojang.com/mc/game/version_manifest_v2.json');
getProductionData().convention(project.layout.projectDirectory.dir('data'))
getProductionDataFormat().convention(MappingIOFormat.ENIGMA_EXPLODED)
getStagingData().convention(project.layout.projectDirectory.dir('staging'))
getStagingDataFormat().convention(MappingIOFormat.ENIGMA_EXPLODED)
getInputs().convention(project.layout.projectDirectory.dir('input'))
Comment on lines +20 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these can be modified to access the properties as if they were fields?

}

@ProjectGetter
private Project getProject() {
return this.@project
}

@DSLProperty
abstract Property<String> getLauncherManifestURL()

@DSLProperty
abstract DirectoryProperty getProductionData()

@DSLProperty
abstract Property<MappingIOFormat> getProductionDataFormat()

@DSLProperty
abstract Property<String> getVersion()

@DSLProperty
abstract DirectoryProperty getStagingData()

@DSLProperty
abstract Property<MappingIOFormat> getStagingDataFormat()

@DSLProperty
abstract DirectoryProperty getInputs()
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public CompassPlugin(ObjectFactory objectFactory) {

@Override
public void apply(Project project) {
final CompassExtension extension = project.getExtensions().create(COMPASS_EXTENSION, CompassExtension.class);
final CompassExtension extension = project.getExtensions().create(COMPASS_EXTENSION, CompassExtension.class, project);
final TaskContainer tasks = project.getTasks();

manifestsDownloader = new ManifestsDownloader(project);
Expand Down
31 changes: 0 additions & 31 deletions src/main/java/org/parchmentmc/compass/CompassExtension.java

This file was deleted.