//version: 1707058017 plugins { id 'com.gtnewhorizons.gtnhconvention' id 'idea' id "dts.typescript-generator" } version = "1.11.2" group= "kamkeel.customnpc-plus" archivesBaseName = "CustomNPC-Plus" def embedMixin = !project.hasProperty("nomixin"); if(!embedMixin){ version += "-nomixin" } // API Task tasks.create('updateAPI', Exec) { description 'Updates (and Inits) git submodules' commandLine 'git', 'submodule', 'update', '--init', '--recursive' group 'CustomNPC+' } // No Mixin Build Task def gradleWrapper = System.getProperty('os.name').toLowerCase().contains('windows') ? 'gradlew.bat' : './gradlew' tasks.create('buildNoMixin', Exec) { description 'Builds mod without embed' group 'CustomNPC+' workingDir project.rootDir commandLine gradleWrapper, 'build', '-Pnomixin' } // No Nashorn Run Tasks tasks.create('runClientNoNashorn', Exec) { description 'Runs the client without Nashorn' group 'CustomNPC+' workingDir project.rootDir commandLine gradleWrapper, 'runClient', '-PnoNashorn' } tasks.create('runServerNoNashorn', Exec) { description 'Runs the server without Nashorn' group 'CustomNPC+' workingDir project.rootDir commandLine gradleWrapper, 'runServer', '-PnoNashorn' } sourceSets.main.java { def apiDir = file('src/api/java') if (!apiDir.exists()) { throw new GradleException("Missing API sources: Run './gradlew updateAPI' or enable checkout submodules in CI.") } srcDirs += apiDir } // ============================================================================ // Scribe fixtures -- an offline generator for CustomNPC+ save data. // // Its own source set, so nothing here reaches the mod jar. It runs CustomNPC+'s // own writeToNBT/writeNBT methods against a bootstrapped-but-unlaunched // Minecraft, and writes the results into a world layout copied from each // controller. See src/fixtures/README.md. // ============================================================================ sourceSets { fixtures { java.srcDirs = ['src/fixtures/java'] compileClasspath += sourceSets.main.output + sourceSets.main.compileClasspath runtimeClasspath += sourceSets.main.output + sourceSets.main.runtimeClasspath } } tasks.register('scribeFixtures', JavaExec) { group 'CustomNPC+' description 'Generates CustomNPC+ save fixtures for Scribe. -Pout=, -Pworlds=' dependsOn 'fixturesClasses' classpath = sourceSets.fixtures.runtimeClasspath mainClass = 'kamkeel.npcs.fixtures.FixtureGenerator' // Off the project dir, because CustomNpcs.getWorldSaveDirectory() resolves "." and // a stray relative write would land in the repo root. workingDir = project.buildDir doFirst { // Resolved against the project directory, not workingDir, so -Pout=build/x means what it // looks like rather than build/build/x. def out = project.hasProperty('out') ? project.file(project.property('out')) : new File(project.buildDir, 'scribe-fixtures') args = [out.absolutePath] if (project.hasProperty('worlds')) { args += ['--worlds', project.property('worlds')] } } } // ============================================================================ // TypeScript Definition Generation Task // Generates .d.ts files from Java API sources for scripting IDE support // ============================================================================ // TypeScript plugin is applied above in the main plugins block tasks.named("generateTypeScriptDefinitions").configure { sourceDirectories = ['src/api/java', 'src/main/java'] outputDirectory = "src/main/resources/assets/${project.property("modId")}/api" apiPackages = ['noppes.npcs.api', 'net.minecraft'] as Set cleanOutputFirst = true // Clean old generated files before regenerating patchesDirectory = "dts-patches" implementationPackages = [ 'noppes.npcs.scripted', 'noppes.npcs.controllers.data', 'noppes.npcs.entity.data', 'noppes.npcs.quests', 'kamkeel.npcs.controllers.data' ] as Set } processResources.dependsOn generateTypeScriptDefinitions sourcesJar.dependsOn generateTypeScriptDefinitions // Javadoc configuration javadoc { options.encoding = 'UTF-8' options.charSet = 'UTF-8' options.docEncoding = 'UTF-8' options.tags = [ 'hookName:a:Hook Name:' ] options.stylesheetFile = file('.github/javadoc/javadoc-theme.css') options.header = file('.github/javadoc/javadoc-header.html').text.replaceAll('\\s+', ' ').trim() options.addBooleanOption('-allow-script-in-comments', true) options.footer = file('.github/javadoc/javadoc-footer.html').text.replaceAll('\\s+', ' ').trim() // Only document the public API, not net.minecraft stubs include 'noppes/npcs/api/**' options.links( 'https://docs.oracle.com/en/java/javase/11/docs/api/' ) javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(11) } } // Modify the existing 'build' task to depend on 'updateAPI' //tasks.apiClasses.dependsOn 'updateAPI'