1- import  me.modmuss50.mpp.PublishModTask 
2- import  me.modmuss50.mpp.platforms.curseforge.Curseforge 
31import  org.gradle.api.tasks.testing.logging.TestExceptionFormat 
42import  org.gradle.api.tasks.testing.logging.TestLogEvent 
53import  org.slf4j.event.Level 
@@ -56,7 +54,6 @@ val dependencyProjects: List<Project> = listOf(
5654dependencyProjects.forEach {
5755	project.evaluationDependsOn(it.path)
5856}
59- project.evaluationDependsOn(" :Changelog" 
6057
6158tasks.withType<JavaCompile >().configureEach {
6259    dependencyProjects.forEach {
@@ -77,6 +74,31 @@ java {
7774	withSourcesJar()
7875}
7976
77+ val  changelogHtml =  configurations.create(" changelogHtml" 
78+ 	isCanBeConsumed =  false 
79+ 	isCanBeResolved =  true 
80+ 	isVisible =  false 
81+ 	attributes {
82+ 		attribute(Usage .USAGE_ATTRIBUTE , objects.named<Usage >(" changelogHtml" 
83+ 	}
84+ }
85+ 
86+ val  changelogMarkdown =  configurations.create(" changelogMarkdown" 
87+ 	isCanBeConsumed =  false 
88+ 	isCanBeResolved =  true 
89+ 	isVisible =  false 
90+ 	attributes {
91+ 		attribute(Usage .USAGE_ATTRIBUTE , objects.named<Usage >(" changelogMarkdown" 
92+ 	}
93+ }
94+ 
95+ fun  Configuration.singleFileContents (): Provider <String > = 
96+ 	incoming
97+ 		.files
98+ 		.elements
99+ 		.map { elements ->  elements.single() }
100+ 		.map { it.asFile.readText() }
101+ 
80102dependencies {
81103	dependencyProjects.forEach {
82104		implementation(it)
@@ -91,6 +113,8 @@ dependencies {
91113		name =  " junit-jupiter-engine" 
92114		version =  jUnitVersion
93115	)
116+ 	changelogHtml(project(" :Changelog" 
117+ 	changelogMarkdown(project(" :Changelog" 
94118}
95119
96120neoForge {
@@ -150,47 +174,6 @@ val sourcesJarTask = tasks.named<Jar>("sourcesJar") {
150174	archiveClassifier.set(" sources" 
151175}
152176
153- 
154- abstract  class  ReadChangelog  : DefaultTask () {
155- 	@get:InputFile
156- 	abstract  val  inputFile:  RegularFileProperty 
157- 
158- 	@get:OutputFile
159- 	abstract  val  outputFile:  RegularFileProperty 
160- 
161- 	@TaskAction
162- 	fun  read () {
163- 		val  text =  inputFile.get().asFile.readText()
164- 		outputFile.get().asFile.writeText(text)
165- 	}
166- }
167- 
168- val  changelogHtmlFile:  Provider <RegularFile > = 
169- 	project(" :Changelog" " changelog.html" 
170- 
171- val  changelogHtmlTask =  tasks.register<ReadChangelog >(" readChangelogHtml" 
172- 	dependsOn(" :Changelog:makeChangelog" 
173- 	inputFile.set(changelogHtmlFile)
174- 	outputFile.set(layout.buildDirectory.file(" intermediates/changelog.html" 
175- }
176- 
177- val  changelogHtmlContent:  Provider <String > =  changelogHtmlTask.flatMap {
178- 	it.outputFile.map { f ->  f.asFile.readText() }
179- }
180- 
181- val  changelogMdFile:  Provider <RegularFile > = 
182- 	project(" :Changelog" " changelog.md" 
183- 
184- val  changelogMdTask =  tasks.register<ReadChangelog >(" readChangelogMd" 
185- 	dependsOn(" :Changelog:makeMarkdownChangelog" 
186- 	inputFile.set(changelogMdFile)
187- 	outputFile.set(layout.buildDirectory.file(" intermediates/changelog.md" 
188- }
189- 
190- val  changelogMdContent:  Provider <String > =  changelogMdTask.flatMap {
191- 	it.outputFile.map { f ->  f.asFile.readText() }
192- }
193- 
194177publishMods {
195178	file.set(tasks.jar.get().archiveFile)
196179	type =  BETA 
@@ -201,7 +184,7 @@ publishMods {
201184	curseforge {
202185		projectId =  curseProjectId
203186		accessToken.set(curseforgeApikey ? :  " 0" 
204- 		changelog.set(changelogHtmlContent )
187+ 		changelog.set(changelogHtml.singleFileContents() )
205188		changelogType =  " html" 
206189		minecraftVersionRange {
207190			start =  minecraftVersionRangeStart
@@ -213,18 +196,14 @@ publishMods {
213196	modrinth {
214197		projectId =  modrinthId
215198		accessToken =  modrinthToken
216- 		changelog.set(changelogMdContent )
199+ 		changelog.set(changelogMarkdown.singleFileContents() )
217200		minecraftVersionRange {
218201			start =  minecraftVersionRangeStart
219202			end =  minecraftVersion
220203		}
221204	}
222205}
223206
224- tasks.withType<PublishModTask > {
225- 	dependsOn(tasks.jar, changelogHtmlTask, changelogMdTask)
226- }
227- 
228207tasks.named<Test >(" test" 
229208	useJUnitPlatform()
230209	include(" mezz/jei/test/**" 
0 commit comments