diff --git a/build.gradle b/build.gradle index 8a4606af..d38d26c9 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ targetCompatibility = JavaVersion.VERSION_16 archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group +def local_bclib = findProject(':BCLib') != null repositories { maven { url "https://maven.dblsaiko.net/" } @@ -33,7 +34,13 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" useApi "vazkii.patchouli:Patchouli:1.17-${project.patchouli_version}" - useApi "com.github.paulevsGitch:BCLib:${project.bclib_version}" + println "Using local BCLib: ${local_bclib}" + if (local_bclib){ + compileOnly(project(":BCLib")) + modRuntimeMapped(project(":BCLib")) + } else { + useApi "com.github.paulevsGitch:BCLib:${project.bclib_version}" + } useOptional "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" useOptional "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}" diff --git a/settings.gradle b/settings.gradle index f91a4fe7..8eab6b85 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,6 @@ pluginManagement { repositories { + jcenter() maven { name = 'Fabric' url = 'https://maven.fabricmc.net/' @@ -7,3 +8,39 @@ pluginManagement { gradlePluginPortal() } } +// #### Custom Settings #### + +//Change the next line to disable local BCLib loading +def allowLocalLibUse = false + +//When true, the local BCLib is also used in commandline builds +def allowLocalLibInConsoleMode = false + +//The path were to look for the local BCLib +def BCLibPath = '../BCLib' + + +// #### Logic #### +def isIDE = properties.containsKey('android.injected.invoked.from.ide') + || (System.getenv("XPC_SERVICE_NAME") ?: "").contains("intellij") + || (System.getenv("XPC_SERVICE_NAME") ?: "").contains(".idea") + || System.getenv("IDEA_INITIAL_DIRECTORY") != null + +println "IntelliJ: ${isIDE}" + +def BCLibFolder = new File( BCLibPath ) +if( allowLocalLibUse && (isIDE || allowLocalLibInConsoleMode) && BCLibFolder.exists() ) { + println "Using local BCLib from '${BCLibFolder}' in IntelliJ" + println "If you do not want to load the local version of BClib" + println "either rename the Folder containing BCLib to something" + println "else, or set 'allowLocalLibUse' in settings.gradle" + println "to false." + println "" + println "If you receive version-errors when launching minecraft" + println "in IntelliJ, make sure you have set up gradle instead" + println "of IntelliJ to compile and run." + + include ':BCLib' + project(":BCLib").projectDir = BCLibFolder + project(':BCLib').buildFileName = './bclib-composit.gradle' +}