buildscript {
    repositories {
        mavenCentral()
        maven {
            name = "forge"
            url = "https://maven.minecraftforge.net"
        }
        maven {
            name = "sonatype"
            url = "https://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
    dependencies {
        classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {
            changing = true
        }
    }
}

apply plugin: 'java'
//apply plugin: 'scala'
apply plugin: 'forge'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
    maven {
        name = "gt"
        url = "https://gregtech.overminddl1.com/"
        metadataSources {
            artifact()
        }
    }
    maven {
        name = "jitpack"
        url = "https://jitpack.io"
    }
   /* flatDir {
        dirs 'libs'
    }*/
}
dependencies {
    implementation "com.github.GTNewHorizons:NotEnoughItems:2.3.19-GTNH:dev"
    implementation "com.github.GTNewHorizons:EnderStorage:master-SNAPSHOT:dev"
    implementation "com.github.GTNewHorizons:waila:master-SNAPSHOT:dev"
    
  //  implementation "mozeintel:ProjectE:1.7.10-PE1.10.1"
}

ext.configFile = file "build.properties"

configFile.withReader {
    def prop = new Properties()
    prop.load(it)
    project.ext.config = new ConfigSlurper().parse prop
}

version = config.mod_version
group = "com.pahimar.ee3" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "EquivalentExchange3"

minecraft {
    version = config.minecraft_version + "-" + config.forge_version

    replaceIn "reference/Reference.java"
    replace "@MOD_VERSION@", "${config.mod_version}.${System.getenv("BUILD_NUMBER") ?: 0}"
    if (project.hasProperty("ee3_sha1_signature")) {
        replace "@FINGERPRINT@", project.ee3_sha1_signature
    }

    replaceIn "api/package-info.java"
    replace "@API_VERSION@", config.api_version

    replaceIn "api/array/package-info.java"
    replace "@API_VERSION@", config.api_version

    replaceIn "api/event/package-info.java"
    replace "@API_VERSION@", config.api_version

    replaceIn "api/exchange/package-info.java"
    replace "@API_VERSION@", config.api_version

    replaceIn "api/knowledge/package-info.java"
    replace "@API_VERSION@", config.api_version

    replaceIn "api/recipe/package-info.java"
    replace "@API_VERSION@", config.api_version

    replaceIn "api/util/package-info.java"
    replace "@API_VERSION@", config.api_version
}

version = "${config.minecraft_version}-${config.mod_version}.${System.getenv("BUILD_NUMBER") ?: 0}"

processResources {
    // exclude xcf files, as they are for development only
    exclude '**/*.xcf'

    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    filesMatching('mcmod.info') {
        expand 'version':project.version, 'mcversion':project.minecraft.version
    }
}

uploadArchives {
    repositories {
        mavenDeployer {
            if (project.hasProperty("forgemaven_url")) {
                logger.info('Publishing to files server')
                repository(url: project.forgemaven_url) {
                    authentication(userName: project.forgemaven_username, password: project.forgemaven_password)
                }
            }

            pom {
                groupId = project.group
                version = project.version
                artifactId = project.archivesBaseName
            }

            pom.project {
                name project.archivesBaseName
                packaging 'jar'
                description 'Equivalent Exchange 3'
                url 'https://github.com/pahimar/Equivalent-Exchange-3/'

                scm {
                    url 'https://github.com/pahimar/Equivalent-Exchange-3/'
                    connection 'scm:git:git://github.com/pahimar/Equivalent-Exchange-3.git'
                    developerConnection 'scm:git:git@github.com/pahimar/Equivalent-Exchange-3.git'
                }

                issueManagement {
                    system 'github'
                    url 'https://github.com/pahimar/Equivalent-Exchange-3/issues'
                }

                licenses {
                    license {
                        name 'GNU Lesser General Public License 3.0'
                        url 'https://www.gnu.org/licenses/lgpl-3.0.txt'
                        distribution 'repo'
                    }
                }

                developers {
                    developer {
                        id 'Pahimar'
                        name 'Pahimar'
                        roles {
                            role 'developer'
                        }
                    }
                }
            }
        }
    }
}
