plugins { id 'java' id 'java-library' id 'maven-publish' id 'gsl-starplane' version '0.2.1-a20241109' id 'me.champeau.mrjar' version '0.1.1' id 'eclipse' } group 'de.geolykt' version '2.0.0' base { archivesName = 'starloader-api' } multiRelease { targetVersions 8, 9 } repositories { mavenCentral() maven { name 'stianloader-maven' url 'https://stianloader.org/maven' } mavenLocal() } starplane { withRAS(rootProject.file("src/main/resources/starloader-api.ras")) eclipseEEA = rootProject.file("src/eclipse-eea") } deployMods { // No external mods need to be used as of yet } runMods { from components["java"] debug false systemProperties.put("classloader.dump", true) } configurations { compileOnlyApi.extendsFrom(galimulatorDependencies) } dependencies { // The launcher - the heart of this project; Note that we now adopt a "bring your own launcher" model // so we don't actually force the usage of micromixin on others; Other projects can make use of more modern // launcher versions or even other variants such as those making use of the spongeian mixin implementation compileOnly "org.stianloader:launcher-micromixin:4.0.0-a20241012" devRuntime "org.stianloader:launcher-micromixin:4.0.0-a20241012" compileOnly "org.stianloader:micromixin-annotations:0.7.1-a20241021" compileOnly "de.geolykt.starloader:starplane-annotations:1.0.0" compileOnlyApi "org.jetbrains:annotations:26.0.2-1" testImplementation 'junit:junit:4.12' testImplementation 'org.ow2.asm:asm-util:9.7' } // Yes, we are using Java 11 to build. But actually Java 8 for compilation. // However, the javadoc tool is absolutely bricked with Java 8 - so we straight up use Java 17. tasks.withType(Javadoc) { javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(17) } } javadoc { options { addBooleanOption('html5', true) tags("apiNote:a:API Notice:", "implSpec:a:Implementation Specification:", "implNote:a:Implementation Notice:") links "https://docs.oracle.com/en/java/javase/17/docs/api/" } // see https://stackoverflow.com/a/56641766 doLast { // Append the fix to the file def searchScript = new File(destinationDir, '/search.js') searchScript.append '\n\n' + 'getURLPrefix = function(ui) {\n' + ' return \'\';\n' + '};\n' } } task sourcesJar(type: Jar, dependsOn: classes) { archiveClassifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { archiveClassifier = 'javadoc' from javadoc.destinationDir } remapJar { archiveClassifier = 'remapped' fromJar jar inputs.file jar.archiveFile } task jarVerification(type: de.geolykt.starloader.gslstarplane.GslVerifyRemapperJarTask, dependsOn: remapJar) { includingGalimulatorJar = true validationJar = remapJar.archiveFile } check { dependsOn jarVerification } build { dependsOn remapJar dependsOn javadoc // I am somewhat sick of surprises concerning broken javadoc references and the likes } publish { dependsOn publishToMavenLocal // Gradle doesn't quite like this line but otherwise I get issues when publishing so what gives? } publishing { publications { plugin(MavenPublication) { publication -> groupId project.group artifactId project.base.archivesName.get() version '2.0.0' from components['java'] artifact sourcesJar artifact javadocJar artifact remapJar } } repositories { if (System.getProperty('publishRepo') != null) { maven { url System.getProperty('publishRepo') allowInsecureProtocol = true } } else { mavenLocal() } } } // Unfortunately Eclipse does not have per-sourceset java versions so // of course it will have quite the issues when seeing java 9 classes in an otherwise // java 8 project. In the end I have opted in using the traditional maven style of dealing with the issue: // Ignoring the java 9 source set. eclipse { classpath { file { whenMerged { entries.removeIf { it.path == 'src/main/java9' } entries.removeIf { it.path == project.file('build/classes/java/main').getAbsolutePath() } entries.removeIf { it.path == project.file('build/classes/java/java9').getAbsolutePath() } } } } }