Skip to content
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dist: trusty

language: groovy
jdk:
- openjdk8
- openjdk17

notifications:
email: false
178 changes: 88 additions & 90 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,131 +1,114 @@
import buildSrc.GroovydocForking

plugins {
id 'java-gradle-plugin'
id 'groovy'
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'org.cadixdev.licenser' version '0.6.1'
id 'net.minecraftforge.gradleutils' version '2.+'
id 'dev.gradleplugins.groovy-gradle-plugin' version '1.6.9'
alias libs.plugins.gradleutils
alias libs.plugins.gitversion
alias libs.plugins.licenser
}

defaultTasks 'updateLicenses', 'build'

ext.buildType = project.hasProperty("buildType") ? buildType : 'RELEASE'
ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
ext.commit = project.hasProperty("commit") ? commit : 'unknown'
ext.buildType = project.hasProperty('buildType') ? buildType : 'RELEASE'
ext.buildNumber = project.hasProperty('buildNumber') ? buildNumber : '0'
ext.ciSystem = project.hasProperty('ciSystem') ? ciSystem : 'unknown'
ext.commit = project.hasProperty('commit') ? commit : 'unknown'

gradleutils.displayName = 'SpongePowered Mixin Gradle Plugin'
gradleutils.vendor = 'SpongePowered'
description = 'Gradle plugin for SpongePowered Mixin'
group = 'org.spongepowered'
version = buildType == 'SNAPSHOT' ? "$buildVersion-SNAPSHOT" : gradleutils.tagOffsetVersion
archivesBaseName = 'mixingradle'
sourceCompatibility = targetCompatibility = '1.8'
version = buildType == 'SNAPSHOT' ? "${gitversion.info.tag}-SNAPSHOT" : gitversion.tagOffset
final projectUrl = 'https://www.spongepowered.org'

if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("The use of the groovydoc task requires the Gradle JVM to be JRE 1.8; please change your Gradle JVM to 1.8")
}
println "Version: $version"

java.toolchain.languageVersion = JavaLanguageVersion.of(8)

repositories {
mavenCentral()
maven {
url 'https://repo.gradle.org/gradle/libs-releases-local/'
}
maven gradleutils.forgeMaven
}

dependencies {
implementation 'com.google.guava:guava:21.0'
implementation 'org.ow2.asm:asm-tree:9.2'
compileOnly libs.gradle

implementation libs.guava
implementation libs.asm.tree
}

processResources {
from 'LICENSE.txt'
duplicatesStrategy 'INCLUDE'
tasks.named('processResources', ProcessResources) {
from 'LICENSE.txt'

duplicatesStrategy = 'INCLUDE'
}

license {
ext {
name = project.name
organization = project.organization
url = project.url
name = 'MixinGradle'
organization = gradleutils.vendor.get()
url = projectUrl
}
include '**/*.groovy'
header = file('HEADER.txt')
ignoreFailures = false
header = rootProject.file('HEADER.txt')
}

tasks.named('groovydoc', Groovydoc) {
enabled = false
}

jar {
manifest.mainAttributes (
"Built-By": System.properties['user.name'],
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
tasks.register('groovydocForked', GroovydocForking) {
description = 'Generates Groovydoc API documentation for the main source code.'
group = JavaBasePlugin.DOCUMENTATION_GROUP

classpath = sourceSets.main.output + sourceSets.main.compileClasspath

source = sourceSets.main.groovy

javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(8)
}
}

tasks.named('jar', Jar) {
manifest.mainAttributes(
'Built-By': System.properties['user.name'],
'Created-By': "${System.properties['java.vm.version']} (${System.properties['java.vm.vendor']})",
"Implementation-Title": project.name,
"Implementation-Version": project.version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
"Implementation-Version": "${project.version}+${ciSystem}-b${buildNumber}.git-${commit}",
)
}

task groovydocJar(type: Jar, dependsOn: groovydoc) {
from groovydoc.destinationDir
tasks.register('groovydocJar', Jar) {
dependsOn groovydocForked
from groovydocForked.destinationDir

archiveClassifier = 'groovydoc'
}

artifacts {
archives jar
archives groovydocJar
tasks.named('assemble') {
dependsOn groovydocJar
}

gradlePlugin {
compatibility {
minimumGradleVersion = '6.6'
}
website = 'http://www.gradle.org/'
vcsUrl = 'https://github.com/SpongePowered/MixinGradle'
plugins {
patcher {
id = 'org.spongepowered.mixin'
implementationClass = 'org.spongepowered.asm.gradle.plugins.MixinGradlePlugin'
displayName = 'SpongePowered Mixin Gradle Plugin'
description = 'Gradle plugin for SpongePowered Mixin'
tags.addAll('spongepowered', 'sponge', 'mixin')
}
website = gitversion.url
vcsUrl = gitversion.url + '.git'

plugins.register('mixingradle') {
id = 'org.spongepowered.mixin'
implementationClass = 'org.spongepowered.asm.gradle.plugins.MixinGradlePlugin'
displayName = 'SpongePowered Mixin Gradle Plugin'
description = 'Gradle plugin for SpongePowered Mixin'
tags = ['spongepowered', 'sponge', 'mixin']
}
automatedPublishing = true
}

publishing {
publications {
pluginMaven(MavenPublication) {
// Automated publishing declares the java component for us

groupId = project.group
version = project.version
artifactId = project.archivesBaseName

pom {
name = project.archivesBaseName
packaging = 'jar'
description = 'MixinGradle'
url = 'http://www.spongepowered.org/'

scm {
url = 'https://github.com/SpongePowered/MixinGradle'
connection = 'scm:git:git://github.com/SpongePowered/MixinGradle.git'
developerConnection = 'scm:git:git@github.com:SpongePowered/MixinGradle.git'
}

issueManagement {
system = 'GitHub Issues'
url = 'https://github.com/SpongePowered/MixinGradle/issues'
}

licenses {
license {
name = 'MIT license'
url = 'http://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
}
}
}
repositories {
if (buildType == 'RELEASE') {
if (project.hasProperty("releaseRepo")) {
if (project.hasProperty('releaseRepo')) {
maven {
credentials {
username = project.releaseRepoUsername
Expand All @@ -134,7 +117,7 @@ publishing {
url project.releaseRepo
}
}
if (project.hasProperty("spongeReleaseRepo")) {
if (project.hasProperty('spongeReleaseRepo')) {
maven {
credentials {
username = project.spongeUsername
Expand All @@ -143,7 +126,7 @@ publishing {
url project.spongeReleaseRepo
}
}
} else if (project.hasProperty("spongeSnapshotRepo")) {
} else if (project.hasProperty('spongeSnapshotRepo')) {
maven {
credentials {
username = project.spongeUsername
Expand All @@ -153,4 +136,19 @@ publishing {
}
}
}

publications.register('pluginMaven', MavenPublication) {
artifact groovydocJar

pom { pom ->
name = gradleutils.displayName
description = project.description

gradleutils.pom.addRemoteDetails(pom)

licenses {
license gradleutils.pom.licenses.MIT
}
}
}
}
16 changes: 16 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id 'java'
alias libs.plugins.licenser
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

license {
ext {
name = 'MixinGradle'
organization = 'SpongePowered'
url = 'https://www.spongepowered.org'
}

header = rootProject.file('../HEADER.txt')
}
5 changes: 5 additions & 0 deletions buildSrc/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rootProject.name = 'buildSrc'

dependencyResolutionManagement.versionCatalogs.register('libs') {
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0'
}
105 changes: 105 additions & 0 deletions buildSrc/src/main/java/buildSrc/GroovydocForking.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* This file is part of MixinGradle, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package buildSrc;

import org.gradle.api.InvalidUserDataException;
import org.gradle.api.file.FileSystemOperations;
import org.gradle.api.internal.tasks.GroovydocAntAction;
import org.gradle.api.provider.Property;
import org.gradle.api.resources.TextResource;
import org.gradle.api.tasks.CacheableTask;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.javadoc.Groovydoc;
import org.gradle.jvm.toolchain.JavaLauncher;
import org.gradle.workers.WorkQueue;
import org.jspecify.annotations.Nullable;

import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Collection;

// This is a Groovydoc task but the Groovydoc ant action runs in a forked JVM using getJavaLauncher()
@CacheableTask
public abstract class GroovydocForking extends Groovydoc {
public abstract @Nested Property<JavaLauncher> getJavaLauncher();

protected abstract @Inject FileSystemOperations getFileSystemOperations();

@Override
protected void generate() {
this.checkGroovyClasspathNonEmpty(this.getGroovyClasspath().getFiles());
File destinationDir = this.getDestinationDir();

try {
this.getDeleter().ensureEmptyDirectory(destinationDir);
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}

FileSystemOperations fsOperations = this.getFileSystemOperations();
File tmpDir = this.getTemporaryDir();
fsOperations.delete((spec) -> spec.delete(tmpDir));
fsOperations.copy((spec) -> spec.from(this.getSource()).into(tmpDir));

WorkQueue queue = this.getWorkerExecutor().processIsolation(spec -> spec.forkOptions(fork -> {
fork.setExecutable(getJavaLauncher().get().getExecutablePath().toString());
}));

queue.submit(GroovydocAntAction.class, (parameters) -> {
parameters.getAntLibraryClasspath().from(this.getClasspath());
parameters.getAntLibraryClasspath().from(this.getGroovyClasspath());
parameters.getSource().convention(this.getSource());
parameters.getDestinationDirectory().fileValue(destinationDir);
parameters.getUse().convention(this.isUse());
parameters.getNoTimestamp().convention(this.isNoTimestamp());
parameters.getNoVersionStamp().convention(this.isNoVersionStamp());
parameters.getWindowTitle().convention(this.getWindowTitle());
parameters.getDocTitle().convention(this.getDocTitle());
parameters.getHeader().convention(this.getHeader());
parameters.getFooter().convention(this.getFooter());
parameters.getOverview().convention(this.getPathToOverview());
parameters.getAccess().convention(this.getAccess());
parameters.getLinks().convention(this.getLinks());
parameters.getTmpDir().fileValue(this.getTemporaryDir());
parameters.getIncludeAuthor().convention(this.getIncludeAuthor());
parameters.getProcessScripts().convention(this.getProcessScripts());
parameters.getIncludeMainForScripts().convention(this.getIncludeMainForScripts());
});
}

private void checkGroovyClasspathNonEmpty(Collection<File> classpath) {
if (classpath.isEmpty()) {
throw new InvalidUserDataException("You must assign a Groovy library to the groovy configuration!");
}
}

private @Nullable String getPathToOverview() {
TextResource overview = this.getOverviewText();
return overview != null ? overview.asFile().getAbsolutePath() : null;
}
}
19 changes: 12 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name=MixinGradle
inceptionYear=2015
packaging=jar
description=MixinGradle
url=https://www.spongepowered.org
organization=SpongePowered
buildVersion=0.7
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configureondemand=true

org.gradle.configuration-cache=true
org.gradle.configuration-cache.parallel=true
org.gradle.configuration-cache.problems=warn

systemProp.org.gradle.unsafe.suppress-gradle-api=true

net.minecraftforge.gradleutils.ide.automatic.sources=true
net.minecraftforge.gradleutils.compilation.defaults=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading