buildscript { repositories { mavenCentral() } dependencies { classpath "org.bdware.bdcontract:simple-ypk-packer:0.6.3" classpath "org.bdware.bdcontract:ypk-deploy-tool:0.7.4" } } plugins { id 'java' id 'java-library' } def moduleName = "backend" def relativePath = "./${moduleName}" def currVersion = "1.3.6" def appName = "contract-java-example" tasks.withType(JavaCompile) { options.compilerArgs << '-Xlint:none' options.compilerArgs << '-Xlint:deprecation' << "-Werror" } sourceSets { main { java { srcDirs 'src/main/java' } resources { srcDir 'src/main/resources' } } test { java { srcDir 'src/test/java' } resources { srcDir 'src/test/resources' } } } dependencies { api 'org.apache.logging.log4j:log4j-core:2.17.2' api 'org.apache.logging.log4j:log4j-api:2.17.2' implementation 'org.bdware.sc:cp:1.9.9' testImplementation 'junit:junit:4.13.2' } task copyLibs(type: Copy) { from configurations.runtimeClasspath into "./build/output/libs/" } task copyYJS(type: Copy) { from "./yjs" into "./build/output/" } //TODO 针对不同的前端,可以仅复制所需的前端代码,而不是整个前端目录。 //比如: from "../front/vite/dist" task copyFront(type: Copy) { from "../front" into "./build/output/assets" } task sourcesJar(type: Jar) { from sourceSets.main.allJava archiveClassifier = 'sources' } task copyAssets(type: Copy) { from "../front" into "./build/output/assets/" } task copyJar(type: Copy, dependsOn: [":${moduleName}:jar", ":${moduleName}:copyLibs"]) { from "./build/libs/${moduleName}.jar" into "./build/output" rename { String fileName -> "${appName}.jar" } doFirst { println "copyJar start" } } task grepCP(dependsOn: ["copyJar"]) { doLast { org.bdware.datanet.YPKPacker.grepJarByCPVersion("${relativePath}/build/output/libs", org.bdware.datanet.CPVersion.cp_1_9_0) org.bdware.datanet.YPKPacker.grepJarByListFile("${relativePath}/build/output/libs", "${relativePath}/grepcp.list") } } tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) tasks.processTestResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) task buildZip(type: Zip, dependsOn: ["copyAssets", "copyJar", "copyYJS", "grepCP", "copyFront"]) { from './build/output/' duplicatesStrategy = DuplicatesStrategy.INCLUDE archiveFileName = "${appName}.zip" destinationDirectory = file('build/') } task buildYPK(dependsOn: ["buildZip"]) { doLast { org.bdware.datanet.YPKPacker.staticPack("${relativePath}/build/${appName}.zip", "${relativePath}/build/${appName}-${currVersion}.ypk") } } task deploy(dependsOn: ["buildYPK"]) { doLast { org.bdware.ypkdeploy.HTTPTool.deployWithYpk("${relativePath}/debugconf.json", "${relativePath}/build/${appName}-${currVersion}.ypk") } }