@@ -18,9 +18,9 @@ plugins {
1818 id ' java'
1919 id ' java-library'
2020 id ' eclipse'
21+ id ' maven-publish'
2122 id ' org.jetbrains.gradle.plugin.idea-ext' version ' 1.1.7'
2223 id ' com.gtnewhorizons.retrofuturagradle' version ' 1.3.+'
23- id ' scala' apply false
2424 id ' net.darkhax.curseforgegradle' version ' 1.0.+' apply false
2525 id ' com.modrinth.minotaur' version ' 2.7.+' apply false
2626 id ' com.diffplug.spotless' version ' 6.13.0' apply false
@@ -66,6 +66,7 @@ propertyDefaultIfUnset("modrinthRelations", "")
6666propertyDefaultIfUnset(" curseForgeProjectId" , " " )
6767propertyDefaultIfUnset(" curseForgeRelations" , " " )
6868propertyDefaultIfUnset(" releaseType" , " release" )
69+ propertyDefaultIfUnset(" customMavenPublishUrl" , " " )
6970propertyDefaultIfUnset(" enableModernJavaSyntax" , false )
7071propertyDefaultIfUnset(" enableSpotless" , false )
7172propertyDefaultIfUnset(" enableJUnit" , false )
@@ -739,6 +740,39 @@ def addModrinthDep(String scope, String type, String name) {
739740 project. modrinth. dependencies. add(dep)
740741}
741742
743+ if (customMavenPublishUrl) {
744+ String publishedVersion = modVersion
745+
746+ publishing {
747+ publications {
748+ create(' maven' , MavenPublication ) {
749+ // noinspection GroovyAssignabilityCheck
750+ from components. java
751+
752+ if (apiPackage) {
753+ artifact apiJar
754+ }
755+
756+ // providers is not available here, use System for getting env vars
757+ groupId = System . getenv(' ARTIFACT_GROUP_ID' ) ?: project. group
758+ artifactId = System . getenv(' ARTIFACT_ID' ) ?: project. name
759+ version = System . getenv(' RELEASE_VERSION' ) ?: publishedVersion
760+ }
761+ }
762+
763+ repositories {
764+ maven {
765+ url = customMavenPublishUrl
766+ allowInsecureProtocol = ! customMavenPublishUrl. startsWith(' https' )
767+ credentials {
768+ username = providers. environmentVariable(' MAVEN_USER' ). getOrElse(' NONE' )
769+ password = providers. environmentVariable(' MAVEN_PASSWORD' ). getOrElse(' NONE' )
770+ }
771+ }
772+ }
773+ }
774+ }
775+
742776
743777// Buildscript updating
744778
0 commit comments