|
1 | | -import java.util.Properties |
2 | | -import org.gradle.api.internal.project.ProjectInternal |
3 | | -import org.gradle.util.internal.VersionNumber |
4 | | - |
5 | 1 | version = "1.12.1" |
6 | 2 |
|
7 | 3 | configurations.compileClasspath { |
@@ -44,91 +40,3 @@ publishingConventions { |
44 | 40 | } |
45 | 41 |
|
46 | 42 | testingConventions { testGradleVersions("7.4", "7.6.5", "8.0.2", "8.14.3") } |
47 | | - |
48 | | -// Turn off classfile lint as long as we still compile with Java 8 |
49 | | -// /org/objectweb/asm/ClassReader.class: Cannot find annotation method 'forRemoval()' in type 'Deprecated' |
50 | | -tasks.compileJava { options.compilerArgs.add("-Xlint:-classfile") } |
51 | | - |
52 | | -val detachedResolver: ProjectInternal.DetachedResolver = (project as ProjectInternal).newDetachedResolver() |
53 | | - |
54 | | -detachedResolver.repositories.ivy { |
55 | | - name = "Modules Properties Repository" |
56 | | - url = project.uri("https://raw.githubusercontent.com/sormuras/modules/main/com.github.sormuras.modules") |
57 | | - metadataSources.artifact() |
58 | | - patternLayout { |
59 | | - artifact("[organisation]/[module].properties") |
60 | | - ivy("[module]/[revision]/ivy.xml") |
61 | | - setM2compatible(true) |
62 | | - } |
63 | | -} |
64 | | - |
65 | | -val modulePropertiesScope = detachedResolver.configurations.dependencyScope("moduleProperties") |
66 | | -val modulePropertiesPath = |
67 | | - detachedResolver.configurations.resolvable("modulePropertiesPath") { extendsFrom(modulePropertiesScope.get()) } |
68 | | -val dep = |
69 | | - detachedResolver.dependencies.add(modulePropertiesScope.name, "com.github.sormuras.modules:modules:1@properties") |
70 | | - |
71 | | -(dep as ExternalModuleDependency).isChanging = true |
72 | | - |
73 | | -val updateUniqueModulesProperties = |
74 | | - tasks.register<UniqueModulesPropertiesUpdate>("updateUniqueModulesProperties") { |
75 | | - skipUpdate = providers.environmentVariable("CI").getOrElse("false").toBoolean() |
76 | | - modulesProperties.from(modulePropertiesPath) |
77 | | - uniqueModulesProperties = |
78 | | - layout.projectDirectory.file( |
79 | | - "src/main/resources/org/gradlex/javamodule/dependencies/unique_modules.properties" |
80 | | - ) |
81 | | - } |
82 | | - |
83 | | -sourceSets.main { |
84 | | - resources.setSrcDirs( |
85 | | - listOf( |
86 | | - updateUniqueModulesProperties.map { |
87 | | - it.uniqueModulesProperties.get().asFile.parentFile.parentFile.parentFile.parentFile.parentFile |
88 | | - } |
89 | | - ) |
90 | | - ) |
91 | | -} |
92 | | - |
93 | | -abstract class UniqueModulesPropertiesUpdate : DefaultTask() { |
94 | | - |
95 | | - @get:Inject abstract val layout: ProjectLayout |
96 | | - |
97 | | - @get:Input abstract val skipUpdate: Property<Boolean> |
98 | | - |
99 | | - @get:InputFiles abstract val modulesProperties: ConfigurableFileCollection |
100 | | - |
101 | | - @get:OutputFile abstract val uniqueModulesProperties: RegularFileProperty |
102 | | - |
103 | | - @TaskAction |
104 | | - fun convert() { |
105 | | - if (skipUpdate.get()) { |
106 | | - return |
107 | | - } |
108 | | - |
109 | | - val modulesToRepoLocation = Properties() |
110 | | - modulesToRepoLocation.load(modulesProperties.singleFile.inputStream()) |
111 | | - val modules = |
112 | | - modulesToRepoLocation |
113 | | - .toSortedMap { e1, e2 -> e1.toString().compareTo(e2.toString()) } |
114 | | - .map { entry -> |
115 | | - val split = entry.value.toString().split("/") |
116 | | - val group = split.subList(4, split.size - 3).joinToString(".") |
117 | | - val name = |
118 | | - split[split.size - 3] |
119 | | - // Special handling of "wrong" entries |
120 | | - .replace("-debug-jdk18on", "-jdk18on") |
121 | | - val version = split[split.size - 2] |
122 | | - Module(entry.key.toString(), "$group:$name", version) |
123 | | - } |
124 | | - .groupBy { it.ga } |
125 | | - .values |
126 | | - .map { moduleList -> moduleList.maxBy { VersionNumber.parse(it.version) } } |
127 | | - .sortedBy { it.name } |
128 | | - |
129 | | - val modulesToCoordinates = modules.map { "${it.name}=${it.ga}\n" } |
130 | | - uniqueModulesProperties.get().asFile.writeText(modulesToCoordinates.joinToString("").trim()) |
131 | | - } |
132 | | - |
133 | | - data class Module(val name: String, val ga: String, val version: String) |
134 | | -} |
0 commit comments