Skip to content

Commit 5d2e039

Browse files
committed
version 1.0.3
1 parent 7c67051 commit 5d2e039

File tree

5 files changed

+152
-98
lines changed

5 files changed

+152
-98
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
*.iml
2+
.idea
23
.DS_Store
34
.gradle
4-
/local.properties
5+
**/local.properties
56
/.idea/caches
67
/.idea/libraries
78
/.idea/modules.xml

plugin-build/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ID=net.kernelpanicsoft.archie.plugin
2-
VERSION=1.0.0
2+
VERSION=1.0.3
33
GROUP=net.kernelpanicsoft.archie
44
DISPLAY_NAME=Archie gradle plugin
55
DESCRIPTION=A gradle plugin for my mods

plugin-build/plugin/build.gradle.kts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import org.gradle.api.internal.artifacts.DefaultModuleIdentifier
22
import org.gradle.api.internal.artifacts.dependencies.DefaultMinimalDependency
33
import org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint
44
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
5+
import org.jetbrains.kotlin.konan.properties.loadProperties
56

67
plugins {
78
kotlin("jvm")
@@ -11,6 +12,20 @@ plugins {
1112
alias(libs.plugins.pluginPublish)
1213
}
1314

15+
val localProperties = kotlin.runCatching { loadProperties("$rootDir/local.properties") }.getOrNull()
16+
17+
val String.prop: String?
18+
get() = rootProject.properties[this] as String?
19+
20+
val String.local: String?
21+
get() = localProperties?.get(this) as String?
22+
23+
val String.env: String?
24+
get() = System.getenv(this)
25+
26+
val String.localOrEnv: String?
27+
get() = localProperties?.get(this)?.toString() ?: System.getenv(this.uppercase())
28+
1429
repositories {
1530
mavenCentral()
1631
gradlePluginPortal()
@@ -72,11 +87,17 @@ gradlePlugin {
7287
publishing {
7388
repositories {
7489
maven {
75-
name = "milosworks"
76-
url = uri("https://maven.milosworks.xyz/releases")
90+
name = "kernelpanic"
91+
val releasesRepoUrl = "https://repo.kernelpanicsoft.net/maven/releases"
92+
val snapshotsRepoUrl = "https://repo.kernelpanicsoft.net/maven/snapshots"
93+
url = uri(
94+
if (project.version.toString().endsWith("SNAPSHOT") || project.version.toString()
95+
.startsWith("0")
96+
) snapshotsRepoUrl else releasesRepoUrl
97+
)
7798
credentials(PasswordCredentials::class) {
78-
username = System.getenv("GRADLE_MAVEN_PUBLISH_KEY")
79-
password = System.getenv("GRADLE_MAVEN_PUBLISH_SECRET")
99+
username = "gradle_maven_publish_key".localOrEnv
100+
password = "gradle_maven_publish_secret".localOrEnv
80101
}
81102
authentication {
82103
create<BasicAuthentication>("basic")

plugin-build/plugin/src/main/kotlin/net/kernelpanicsoft/archie/plugin.gradle.kts

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package net.kernelpanicsoft.archie
33
import net.fabricmc.loom.api.LoomGradleExtensionAPI
44
import net.fabricmc.loom.util.ModPlatform
55
import net.kernelpanicsoft.archie.plugin.ModResourcesExtension
6-
import net.kernelpanicsoft.archie.plugin.patchedFMLModType
76
import org.jetbrains.kotlin.konan.file.file
87
import java.nio.file.FileSystem
98
import java.nio.file.FileSystems
@@ -13,7 +12,7 @@ val extension = extensions.create<ModResourcesExtension>("modResources")
1312
val loom = extensions.getByType<LoomGradleExtensionAPI>()
1413

1514
val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
16-
extension.versions.convention(provider {
15+
extension.versions = provider {
1716
val ret = versionCatalog.versionAliases.associate {
1817
// both "." and "-" cause issues with expand :/
1918
it.replace(".", "_") to versionCatalog.findVersion(it).get().requiredVersion
@@ -32,12 +31,12 @@ extension.versions.convention(provider {
3231

3332
else -> ret
3433
}
35-
})
36-
extension.properties.convention(provider {
34+
}
35+
extension.properties = provider {
3736
project.properties.mapKeys {
3837
it.key.replace(".", "_")
3938
}.mapValues { it.value.toString() }
40-
})
39+
}
4140

4241
// build logic
4342

@@ -105,6 +104,19 @@ abstract class PatchFMLModType : TransformAction<PatchFMLModType.Parameters>
105104
}
106105

107106
val artifactType: Attribute<String> = Attribute.of("artifactType", String::class.java)
107+
val patchedFMLModType = Attribute.of("patchedFMLModType", Boolean::class.javaObjectType)
108+
109+
val bundleRuntimeLibraryConfiguration: Configuration by configurations.creating {
110+
exclude(group = "com.mojang")
111+
exclude(group = "org.jetbrains.kotlin")
112+
exclude(group = "org.jetbrains.kotlinx")
113+
}
114+
115+
val runtimeLibraryConfiguration: Configuration by configurations.creating {
116+
exclude(group = "com.mojang")
117+
exclude(group = "org.jetbrains.kotlin")
118+
exclude(group = "org.jetbrains.kotlinx")
119+
}
108120

109121
dependencies {
110122
attributesSchema {
@@ -120,6 +132,37 @@ dependencies {
120132
to.attribute(patchedFMLModType, true).attribute(artifactType, "jar")
121133
}
122134

123-
extensions.add("loom", project.extensions.getByName("loom"))
135+
// extensions.add("loom", project.extensions.getByName("loom"))
124136
}
125137

138+
afterEvaluate {
139+
dependencies {
140+
bundleRuntimeLibraryConfiguration.resolvedConfiguration.resolvedArtifacts.forEach {
141+
"include"(it.moduleVersion.id.toString())
142+
when (project.extensions.getByType<LoomGradleExtensionAPI>().platform.get())
143+
{
144+
ModPlatform.NEOFORGE ->
145+
"localRuntime"(it.moduleVersion.id.toString()) {
146+
attributes {
147+
attribute(patchedFMLModType, true)
148+
}
149+
}
150+
151+
else -> Unit
152+
}
153+
}
154+
runtimeLibraryConfiguration.resolvedConfiguration.resolvedArtifacts.forEach {
155+
when (project.extensions.getByType<LoomGradleExtensionAPI>().platform.get())
156+
{
157+
ModPlatform.NEOFORGE ->
158+
"localRuntime"(it.moduleVersion.id.toString()) {
159+
attributes {
160+
attribute(patchedFMLModType, true)
161+
}
162+
}
163+
164+
else -> Unit
165+
}
166+
}
167+
}
168+
}

0 commit comments

Comments
 (0)