From 2441cb4a51fabb3f2659d353a8006bd7608080a7 Mon Sep 17 00:00:00 2001 From: Liplum Date: Thu, 21 Dec 2023 15:57:11 +0800 Subject: [PATCH] default path for icon --- main/src/assets/Asset.kt | 9 +++++---- main/src/dsl/GradleKts.kt | 23 ++++++++++++----------- main/src/dsl/TypeAlias.kt | 12 ------------ main/src/plugin/Java.kt | 2 +- 4 files changed, 18 insertions(+), 28 deletions(-) delete mode 100644 main/src/dsl/TypeAlias.kt diff --git a/main/src/assets/Asset.kt b/main/src/assets/Asset.kt index 1d9c368..c62393b 100644 --- a/main/src/assets/Asset.kt +++ b/main/src/assets/Asset.kt @@ -38,13 +38,14 @@ open class MindustryAssetsExtension( */ @JvmField val _icon = proj.fileProp().apply { + val inProj = proj.layout.projectDirectory.file("icon.png").asFile + val inRoot = proj.rootProject.layout.projectDirectory.file("icon.png").asFile convention( findFileInOrder( - proj.layout.projectDirectory.file("icon.png").asFile, - proj.layout.projectDirectory.file("icon.png").asFile, - ) + inProj, + inRoot, + ) ?: inRoot ) - } /** diff --git a/main/src/dsl/GradleKts.kt b/main/src/dsl/GradleKts.kt index 784bf27..305c27c 100644 --- a/main/src/dsl/GradleKts.kt +++ b/main/src/dsl/GradleKts.kt @@ -6,6 +6,7 @@ import org.gradle.api.* import org.gradle.api.artifacts.Configuration import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.Directory +import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.SourceDirectorySet import org.gradle.api.plugins.ExtensionContainer import org.gradle.api.plugins.PluginContainer @@ -27,47 +28,47 @@ fun ExtensionContainer.getOrNull(): T? { } internal -fun Project.stringProp() = +fun Project.stringProp(): Property = objects.property(String::class.java) internal -fun Project.boolProp() = +fun Project.boolProp(): Property = objects.property(Boolean::class.java) internal -fun Project.stringsProp() = +fun Project.stringsProp(): ListProperty = objects.listProperty(String::class.java) internal inline -fun Project.listProp() = +fun Project.listProp(): ListProperty = objects.listProperty(T::class.java) internal inline -fun Project.mapProp() = +fun Project.mapProp(): MapProperty = project.objects.mapProperty(TK::class.java, TV::class.java) internal inline -fun Project.setProp() = +fun Project.setProp(): SetProperty = objects.setProperty(T::class.java) internal inline -fun Project.prop() = +fun Project.prop(): Property = objects.property(T::class.java) internal -fun Project.dirProp() = +fun Project.dirProp(): DirectoryProperty = objects.directoryProperty() internal -fun Project.sourceDirectorySet(name: String, displayName: String) = +fun Project.sourceDirectorySet(name: String, displayName: String): SourceDirectorySet = objects.sourceDirectorySet(name, displayName) internal -fun Project.fileProp() = +fun Project.fileProp(): Property = objects.property(File::class.java) internal -fun Project.configurationFileCollection() = +fun Project.configurationFileCollection(): ConfigurableFileCollection = objects.fileCollection() internal inline diff --git a/main/src/dsl/TypeAlias.kt b/main/src/dsl/TypeAlias.kt deleted file mode 100644 index a5fc461..0000000 --- a/main/src/dsl/TypeAlias.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.github.liplum.dsl - -import org.gradle.api.file.DirectoryProperty -import org.gradle.api.provider.ListProperty -import org.gradle.api.provider.Property -import java.io.File - -typealias StringProp = Property -typealias BoolProp = Property -typealias StringsProp = ListProperty -typealias DirProp = DirectoryProperty -typealias FileProp = Property \ No newline at end of file diff --git a/main/src/plugin/Java.kt b/main/src/plugin/Java.kt index 85a1528..20a5a2e 100644 --- a/main/src/plugin/Java.kt +++ b/main/src/plugin/Java.kt @@ -79,7 +79,7 @@ class MindustryJavaPlugin : Plugin { if (deployX.outputMod) { from(assets.assets) from(assets._icon) - from(tasks.getByPath(R.task.genModHjson)) + from(tasks.findByPath(R.task.genModHjson)) } } }