Skip to content

Commit

Permalink
fix Mindustry maven issue
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Jun 12, 2024
1 parent 94e65b9 commit 3000903
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
5 changes: 3 additions & 2 deletions TestProjectKt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.9.20"
id("io.github.liplum.mgpp") version "1.3.2"
id("io.github.liplum.mgpp") version "1.4.0"
}

sourceSets {
Expand Down Expand Up @@ -36,6 +36,7 @@ dependencies {
open class TestOutputTask : DefaultTask() {
val outputFile = project.objects.property<File>()
@OutputFile get

@TaskAction
fun test() {
}
Expand Down Expand Up @@ -146,7 +147,7 @@ tasks.withType<Jar> {
tasks.test {
useJUnitPlatform()
}
tasks.withType<JavaCompile>{
tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.code.style=official
pluginName=PlumyMindustryGradlePlugin
arcVersion=v146
mgppVersion=1.3.3
mgppVersion=1.4.0
22 changes: 19 additions & 3 deletions main/src/io/github/liplum/mindustry/BuildScript.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,20 @@ import java.net.URL
* You can call this in [RepositoryHandler] closure
*/
fun RepositoryHandler.mindustryRepo(
): MavenArtifactRepository = maven { repo ->
repo.name = "mindustry-center"
repo.url = URI("https://www.jitpack.io")
): MavenArtifactRepository = run {
val mindustryRepo = maven { repo ->
repo.name = "mindustry-maven"
// Jitpack was broken for Mindustry and Arc
repo.url = URI("https://raw.githubusercontent.com/Zelaux/MindustryRepo/master/repository")
}
// jitpack after Mindustry repo
maven { repo ->
repo.name = "jitpack"
repo.url = URI("https://www.jitpack.io")
}
mindustryRepo
}

/**
* Import the dependencies of Mindustry.
* It will take those into account:
Expand All @@ -43,6 +53,7 @@ fun Project.importMindustry() = afterEvaluateThis {
// Arc
arc.whenAvailable("arc-core", ::addMindustry)
}

/**
* Import the dependencies of Mindustry.
* It will take those into account:
Expand All @@ -67,6 +78,7 @@ fun Project.importMindustry(configurationName: String) = afterEvaluateThis {
// Arc
arc.whenAvailable("arc-core", ::addSpecificDependency)
}

internal
fun Dependency.tryJitpackResolve(module: String): String? {
// e.g.:com,github,anuken,arc
Expand All @@ -79,19 +91,23 @@ fun Dependency.tryJitpackResolve(module: String): String? {
val code: Int = huc.responseCode
return if (code == 404) null else resolve(module)
}

internal
fun Project.addMindustry(dependencyNotation: String) {
compileOnly(dependencyNotation)
testImplementation(dependencyNotation)
}

internal
fun Project.testImplementation(dependencyNotation: String) {
addDependency("testImplementation", dependencyNotation)
}

internal
fun Project.compileOnly(dependencyNotation: String) {
addDependency("compileOnly", dependencyNotation)
}

internal
fun Project.addDependency(configurationName: String, dependencyNotation: String) {
configurations.getByName(configurationName).dependencies.add(
Expand Down
4 changes: 2 additions & 2 deletions main/src/io/github/liplum/mindustry/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class MindustryPlugin : Plugin<Project> {
/**
* [The Mindustry repo on Jitpack](https://github.com/anuken/mindustry)
*/
const val MindustryJitpackRepo = "com.github.anuken.mindustry"
const val MindustryJitpackRepo = "com.github.Anuken.Mindustry"
/**
* [The mirror repo of Mindustry on Jitpack](https://github.com/anuken/mindustryjitpack)
*/
Expand All @@ -188,7 +188,7 @@ class MindustryPlugin : Plugin<Project> {
/**
* [The Arc repo on Jitpack](https://github.com/anuken/arc)
*/
const val ArcJitpackRepo = "com.github.anuken.arc"
const val ArcJitpackRepo = "com.github.Anuken.Arc"
/**
* The main class of desktop launcher.
*/
Expand Down

0 comments on commit 3000903

Please sign in to comment.