diff --git a/build.gradle b/build.gradle index 913152a..f3274de 100644 --- a/build.gradle +++ b/build.gradle @@ -62,6 +62,7 @@ propertyDefaultIfUnset("generateGradleTokenClass", "") propertyDefaultIfUnset("gradleTokenModId", "") propertyDefaultIfUnset("gradleTokenModName", "") propertyDefaultIfUnset("gradleTokenVersion", "") +propertyDefaultIfUnset("useSrcApiPath", false) propertyDefaultIfUnset("includeWellKnownRepositories", true) propertyDefaultIfUnset("includeCommonDevEnvMods", true) propertyDefaultIfUnset("noPublishedSources", false) @@ -105,9 +106,16 @@ if (!getFile(targetPackageJava).exists() && !getFile(targetPackageScala).exists( } if (apiPackage) { - targetPackageJava = javaSourceDir + modGroupPath + '/' + apiPackagePath - targetPackageScala = scalaSourceDir + modGroupPath + '/' + apiPackagePath - targetPackageKotlin = kotlinSourceDir + modGroupPath + '/' + apiPackagePath + final String endApiPath = modGroupPath + '/' + apiPackagePath + if (useSrcApiPath) { + targetPackageJava = 'src/api/java' + endApiPath + targetPathScala = 'src/api/scala' + endApiPath + targetPathKotlin = 'src/api/kotlin' + endApiPath + } else { + targetPackageJava = javaSourceDir + endApiPath + targetPackageScala = scalaSourceDir + endApiPath + targetPackageKotlin = kotlinSourceDir + endApiPath + } if (!getFile(targetPackageJava).exists() && !getFile(targetPackageScala).exists() && !getFile(targetPackageKotlin).exists()) { throw new GradleException("Could not resolve \"apiPackage\"! Could not find ${targetPackageJava} or ${targetPackageScala} or ${targetPackageKotlin}") } @@ -675,6 +683,19 @@ jar { it.isDirectory() ? it : zipTree(it) } } + + if (useSrcApiPath && apiPackage) { + from sourceSets.api.output + dependsOn apiClasses + + include "${apiPackage}/**" + include "assets/**" + include "mcmod.info" + include "pack.mcmeta" + if (accessTransformersFile) { + include "META-INF/${accessTransformersFile}" + } + } } // Configure default run tasks diff --git a/gradle.properties b/gradle.properties index 93c5917..3b3e38f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -43,6 +43,9 @@ gradleTokenVersion = VERSION # Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api apiPackage = +# If you want to keep your API code in src/api instead of src/main +useSrcApiPath = false + # Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/ # There can be multiple files in a comma-separated list. # Example value: mymodid_at.cfg,jei_at.cfg