fix transitive-aw issues
All checks were successful
Publish to snapshot maven / build (push) Successful in 24s

This commit is contained in:
moehreag 2024-06-13 00:23:58 +02:00
parent c4c62632c2
commit ad2e3798f3
3 changed files with 22 additions and 11 deletions

View file

@ -7,7 +7,7 @@ plugins {
} }
group = "dev.frogmc" group = "dev.frogmc"
version = "0.0.1-alpha.1" version = "0.0.1-alpha.2"
repositories { repositories {
maven { maven {

View file

@ -5,6 +5,7 @@ import com.electronwill.nightconfig.toml.TomlParser
import com.google.common.hash.Hashing import com.google.common.hash.Hashing
import dev.frogmc.phytotelma.Constants import dev.frogmc.phytotelma.Constants
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.plugins.JavaPlugin import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.plugins.JavaPluginExtension
import org.objectweb.asm.* import org.objectweb.asm.*
@ -14,10 +15,7 @@ import java.nio.file.Path
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import java.util.regex.Pattern import java.util.regex.Pattern
import java.util.stream.Stream import java.util.stream.Stream
import kotlin.io.path.bufferedReader import kotlin.io.path.*
import kotlin.io.path.exists
import kotlin.io.path.readBytes
import kotlin.io.path.writeBytes
object AccessWidener { object AccessWidener {
@ -28,7 +26,7 @@ object AccessWidener {
private val SEPARATOR = "[\\t ]+".toRegex() private val SEPARATOR = "[\\t ]+".toRegex()
private fun getAWFile(project: Project): Path? { private fun getAWFile(project: Project): Path? {
project.extensions.getByType(JavaPluginExtension::class.java).sourceSets.forEach { set -> project.extensions.findByType(JavaPluginExtension::class.java)?.sourceSets?.forEach { set ->
set.resources.filter { it.name == Constants.MOD_METADATA_FILE }.firstOrNull { set.resources.filter { it.name == Constants.MOD_METADATA_FILE }.firstOrNull {
if (it == null) { if (it == null) {
println("Please make sure a 'frog.mod.toml' file is present in the mod's resources!") println("Please make sure a 'frog.mod.toml' file is present in the mod's resources!")
@ -45,10 +43,24 @@ object AccessWidener {
} }
private fun findDependencyAWs(project: Project): List<Path> { private fun findDependencyAWs(project: Project): List<Path> {
return project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME) val conf = project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
.resolvedConfiguration.firstLevelModuleDependencies.flatMap { dep -> return conf.dependencies.filterIsInstance<ProjectDependency>().map {
dep.moduleArtifacts getAWFile(it.dependencyProject)
}.map { it.file }.map { it.toPath() }.toList() }.plus(conf.resolvedConfiguration.firstLevelModuleDependencies.flatMap {
dep -> dep.moduleArtifacts
}.map { it.file.toPath() }.filter { it.exists() && it.isRegularFile() }.map {
FileSystems.newFileSystem(it).use {fs ->
val metadata = fs.getPath(Constants.MOD_METADATA_FILE)
if (metadata.exists()) {
return@map null
} else {
PARSER.parse(it, FileNotFoundAction.READ_NOTHING)
.get<String>("frog.extensions.accesswidener")?.let { name ->
return@map it.resolveSibling(name)
}
}
}
}.toList()).filterNotNull().also { println(it) }
} }
fun needsUpdate(project: Project): Boolean { fun needsUpdate(project: Project): Boolean {

View file

@ -45,7 +45,6 @@ object Nester {
} }
} }
} }
//}
configuration.resolvedConfiguration.firstLevelModuleDependencies.forEach { dep -> configuration.resolvedConfiguration.firstLevelModuleDependencies.forEach { dep ->
dep.moduleArtifacts.forEach { artifact -> dep.moduleArtifacts.forEach { artifact ->
val location = addMetadata( val location = addMetadata(