|
| 1 | +import org.gradle.util.GradleVersion |
| 2 | +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar |
| 3 | +import io.freefair.gradle.plugins.maven.javadoc.JavadocLinkUtil |
| 4 | + |
| 5 | +plugins { |
| 6 | + id 'dev.gradleplugins.java-gradle-plugin' |
| 7 | + id 'idea' |
| 8 | + id 'eclipse' |
| 9 | + id 'maven-publish' |
| 10 | + alias libs.plugins.licenser |
| 11 | + alias libs.plugins.gradleutils |
| 12 | + alias libs.plugins.javadoc.links |
| 13 | + alias libs.plugins.plugin.publish |
| 14 | + alias libs.plugins.shadow |
| 15 | +} |
| 16 | + |
| 17 | +final rootBuild = gradle.includedBuild('AccessTransformers') |
| 18 | + |
| 19 | +final projectDisplayName = 'AccessTransformers Gradle Plugin' |
| 20 | +final projectArtifactId = base.archivesName = 'accesstransformers-gradle' |
| 21 | +description = 'Enables Gradle projects to use AccessTransformers on dependencies with minimal hassle.' |
| 22 | +group = 'net.minecraftforge' |
| 23 | +version = gitversion.tagOffset |
| 24 | + |
| 25 | +println "Version: $version" |
| 26 | + |
| 27 | +java.toolchain.languageVersion = JavaLanguageVersion.of 8 |
| 28 | + |
| 29 | +repositories { |
| 30 | + maven { url = 'https://maven.minecraftforge.net' } |
| 31 | + mavenCentral() |
| 32 | +} |
| 33 | + |
| 34 | +dependencies { |
| 35 | + // Utils |
| 36 | + implementation libs.bundles.utils |
| 37 | + |
| 38 | + // Static Analysis |
| 39 | + compileOnly libs.nulls |
| 40 | +} |
| 41 | + |
| 42 | +// Removes local Gradle API from compileOnly. This is a workaround for bugged plugins. |
| 43 | +// TODO [GradleUtils][GradleAPI] Remove this once they are fixed. |
| 44 | +// Publish Plugin: https://github.com/gradle/plugin-portal-requests/issues/260 |
| 45 | +// Shadow: https://github.com/GradleUp/shadow/pull/1422 |
| 46 | +afterEvaluate { project -> |
| 47 | + project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) { compileOnly -> |
| 48 | + compileOnly.dependencies.remove project.dependencies.gradleApi() |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +license { |
| 53 | + header = new File(rootBuild.projectDir, '/LICENSE-header.txt') |
| 54 | + newLine = false |
| 55 | + exclude '**/*.properties' |
| 56 | +} |
| 57 | + |
| 58 | +tasks.named('jar', Jar) { |
| 59 | + archiveClassifier = 'thin' |
| 60 | +} |
| 61 | + |
| 62 | +tasks.named('shadowJar', ShadowJar) { |
| 63 | + enableRelocation = true |
| 64 | + archiveClassifier = null |
| 65 | + relocationPrefix = 'net.minecraftforge.accesstransformers.gradle.shadow' |
| 66 | +} |
| 67 | + |
| 68 | +tasks.withType(Javadoc).configureEach { |
| 69 | + javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of 23 } |
| 70 | + |
| 71 | + options { StandardJavadocDocletOptions options -> |
| 72 | + options.links( |
| 73 | + // Manually included here, since the one at javadoc.io is ass |
| 74 | + JavadocLinkUtil.getGradleApiLink(GradleVersion.version(libs.versions.gradle.get())) |
| 75 | + ) |
| 76 | + |
| 77 | + options.windowTitle = projectDisplayName + project.version |
| 78 | + options.tags 'apiNote:a:API Note:', 'implNote:a:Implementation Note:' |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +changelog { |
| 83 | + fromBase() |
| 84 | + publishAll = false |
| 85 | +} |
| 86 | + |
| 87 | +gradlePlugin { |
| 88 | + website.set gitversion.url |
| 89 | + vcsUrl.set gitversion.url + '.git' |
| 90 | + |
| 91 | + compatibility { |
| 92 | + minimumGradleVersion = libs.versions.gradle.get() |
| 93 | + } |
| 94 | + |
| 95 | + java { |
| 96 | + withSourcesJar() |
| 97 | + withJavadocJar() |
| 98 | + } |
| 99 | + |
| 100 | + plugins.register('accesstransformers') { |
| 101 | + id = 'net.minecraftforge.accesstransformers' |
| 102 | + implementationClass = 'net.minecraftforge.accesstransformers.gradle.AccessTransformersPlugin' |
| 103 | + displayName = projectDisplayName |
| 104 | + description = project.description |
| 105 | + tags = ['minecraftforge'] |
| 106 | + } |
| 107 | +} |
| 108 | + |
| 109 | +publishing { |
| 110 | + publications.register('pluginMaven', MavenPublication) { |
| 111 | + artifactId = projectArtifactId |
| 112 | + |
| 113 | + changelog.publish it |
| 114 | + |
| 115 | + pom { pom -> |
| 116 | + name = projectDisplayName |
| 117 | + description = project.description |
| 118 | + |
| 119 | + gradleutils.pom.setGitHubDetails pom |
| 120 | + |
| 121 | + licenses { |
| 122 | + license gradleutils.pom.licenses.LGPLv2_1 |
| 123 | + } |
| 124 | + |
| 125 | + developers { |
| 126 | + developer gradleutils.pom.developers.Jonathing |
| 127 | + } |
| 128 | + } |
| 129 | + } |
| 130 | + |
| 131 | + repositories { |
| 132 | + maven gradleutils.getPublishingForgeMaven(new File(rootBuild.projectDir, 'repo')) |
| 133 | + } |
| 134 | +} |
| 135 | + |
| 136 | +idea.module { downloadSources = downloadJavadoc = true } |
0 commit comments