kopia lustrzana https://github.com/JOSM/MapWithAI
Temporarily generate manifest for update site until v0.8.1 for the Gradle JOSM plugin is released
Signed-off-by: Taylor Smock <tsmock@fb.com>pull/1/head
rodzic
2b9c88040c
commit
c81d0f24b5
50
build.gradle
50
build.gradle
|
@ -1,9 +1,11 @@
|
|||
import groovy.xml.XmlParser
|
||||
import net.ltgt.gradle.errorprone.CheckSeverity
|
||||
import org.openstreetmap.josm.gradle.plugin.config.JosmManifest
|
||||
import org.openstreetmap.josm.gradle.plugin.task.GeneratePluginList
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.util.stream.Collectors
|
||||
|
||||
plugins {
|
||||
id "com.diffplug.spotless" version "6.3.0"
|
||||
|
@ -275,6 +277,47 @@ spotbugsMain {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a manifest map
|
||||
* @param manifest The manifest to convert
|
||||
* @return The map
|
||||
* @deprecated In v0.8.1 there will be a GenerateJarManifest class
|
||||
*/
|
||||
@Deprecated
|
||||
Map<String, String> createUpdateManifest(JosmManifest manifest) {
|
||||
def returnMap = new TreeMap<String, String>();
|
||||
// Required fields first
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_MIN_JOSM_VERSION, manifest.minJosmVersion, false)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_VERSION, project.version.toString(), false)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_MAIN_CLASS, manifest.mainClass, false)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_DESCRIPTION, manifest.description, false)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.AUTHOR, manifest.author)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_MIN_JAVA_VERSION, manifest.minJavaVersion)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_PLATFORM, manifest.platform)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_PROVIDES, manifest.provides)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_EARLY, manifest.loadEarly)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_ICON, manifest.iconPath)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_DEPENDENCIES, manifest.pluginDependencies)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_LOAD_PRIORITY, manifest.loadPriority)
|
||||
putIfNotNull(returnMap, JosmManifest.Attribute.PLUGIN_CAN_LOAD_AT_RUNTIME, manifest.canLoadAtRuntime)
|
||||
|
||||
return returnMap
|
||||
}
|
||||
|
||||
static putIfNotNull(Map<String, String> map, JosmManifest.Attribute attribute, Object value, boolean optional = true) {
|
||||
if (value instanceof Provider) {
|
||||
value = value.getOrNull()
|
||||
}
|
||||
if (value instanceof Collection) {
|
||||
value = (value as Collection).stream().map(Object::toString).collect(Collectors.joining(";"))
|
||||
}
|
||||
if (value != null && !value.toString().trim().isEmpty()) {
|
||||
map.put(attribute.manifestKey, value.toString());
|
||||
} else if (!optional) {
|
||||
throw new IllegalArgumentException("Attribute " + attribute.manifestKey + " cannot be null or empty");
|
||||
}
|
||||
}
|
||||
|
||||
task generateSnapshotUpdateSite(type: GeneratePluginList) {
|
||||
dependsOn(tasks.processResources)
|
||||
|
||||
|
@ -289,7 +332,12 @@ task generateSnapshotUpdateSite(type: GeneratePluginList) {
|
|||
return "data:image/" + contentType + ";base64," + Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(file.toURI())));
|
||||
}
|
||||
}
|
||||
it.addPlugin("$archivesBaseName-dev.jar", project.josm.manifest.createJosmPluginJarManifest(), new URL(pluginDownloadUrl))
|
||||
/**
|
||||
* Generate a plugin jar manifest map
|
||||
* @deprecated GenerateJarManifest.kt was added after v0.8.0
|
||||
*/
|
||||
def manifest = createUpdateManifest(project.josm.manifest as JosmManifest)
|
||||
it.addPlugin("$archivesBaseName-dev.jar", manifest, new URL(pluginDownloadUrl))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue