From 7c6b922b7b68865a27d7a2cea1cc84c976cc811e Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 20 Feb 2018 11:42:39 -0800 Subject: [PATCH 1/6] Added assertj for testing. --- build.gradle | 3 ++- gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index a4c8ade21..d57c7f769 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,8 @@ dependencies { compileOnly 'p2:org.eclipse.jdt.launching:3.8.0.v20150527-0946' compileOnly 'p2:org.eclipse.emf.ecore:2.11.2.v20160208-0816' // testing - testCompile "junit:junit:${VER_JUNIT}" + testCompile "junit:junit:4.12" + testCompile "org.assertj:assertj-core:3.9.0" } test { diff --git a/gradle.properties b/gradle.properties index fe43d05f4..b54b6ed89 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,5 +22,5 @@ VER_SPOTLESS_LIB=1.5.1 # OSGi VER_BNDLIB=3.5.0 -# Testing -VER_JUNIT=4.12 +# OSGi in Mars.1, latest uploaded to MavenCentral so far +VER_ECLIPSE_OSGI=3.10.101.v20150820-1432 From 3741e09ce7c928e271aafb86f2f1fbc303ff9088 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 20 Feb 2018 11:59:00 -0800 Subject: [PATCH 2/6] Artifact parsing works. --- .../diffplug/gradle/GoomphCacheLocations.java | 14 + .../java/com/diffplug/gradle/ZipMisc.java | 12 + .../gradle/eclipse/MavenCentralMapping.java | 115 + .../eclipse/MavenCentralMappingTest.java | 49 + src/test/resources/artifacts-4.6.3.xml | 16201 ++++++++++++++++ src/test/resources/placeholder | 0 6 files changed, 16391 insertions(+) create mode 100644 src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java create mode 100644 src/test/java/com/diffplug/gradle/eclipse/MavenCentralMappingTest.java create mode 100644 src/test/resources/artifacts-4.6.3.xml delete mode 100644 src/test/resources/placeholder diff --git a/src/main/java/com/diffplug/gradle/GoomphCacheLocations.java b/src/main/java/com/diffplug/gradle/GoomphCacheLocations.java index adf7d2d0c..942ea14bd 100644 --- a/src/main/java/com/diffplug/gradle/GoomphCacheLocations.java +++ b/src/main/java/com/diffplug/gradle/GoomphCacheLocations.java @@ -62,6 +62,20 @@ public static void initFromProject(Project project) { } } + /** + * {@link MavenCentralMap} needs to look at p2 metadata + * to know what the version numbers are for the specific + * bundles of a given eclipse release are. + * + * Rather than downloading this metadata over and over, we only + * download it once, and cache the results here. + */ + public static File eclipseReleaseMetadata() { + return defOverride(ROOT + "/eclipse-release-metadata", override_eclipseReleaseMetadata); + } + + public static File override_eclipseReleaseMetadata = null; + /** * When Goomph creates an IDE for you, it must * also create an eclipse workspace. Unfortunately, diff --git a/src/main/java/com/diffplug/gradle/ZipMisc.java b/src/main/java/com/diffplug/gradle/ZipMisc.java index d8b6e26cd..b073cb9c2 100644 --- a/src/main/java/com/diffplug/gradle/ZipMisc.java +++ b/src/main/java/com/diffplug/gradle/ZipMisc.java @@ -25,6 +25,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.StandardCharsets; +import java.util.Enumeration; import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; @@ -56,6 +57,17 @@ public static void read(File input, String toRead, Throwing.Specific.Consumer entries = file.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + System.err.println(" available: " + entry.getName()); + } + } + } } } diff --git a/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java new file mode 100644 index 000000000..0939f4eb2 --- /dev/null +++ b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java @@ -0,0 +1,115 @@ +/* + * Copyright 2016 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.gradle.eclipse; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.osgi.framework.Version; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; + +import com.diffplug.common.base.Box; +import com.diffplug.common.base.Errors; +import com.diffplug.common.io.Files; +import com.diffplug.common.io.Resources; +import com.diffplug.gradle.FileMisc; +import com.diffplug.gradle.GoomphCacheLocations; +import com.diffplug.gradle.ZipMisc; +import com.diffplug.gradle.pde.EclipseRelease; + +/** Maps eclipse jars to their mavenCentral artifact ids and versions based on their official release. */ +public class MavenCentralMapping { + private static final EclipseRelease FIRST_ON_CENTRAL = EclipseRelease.official("4.6.2"); + + private static final String PLATFORM = "org.eclipse.platform"; + private static final String JDT = "org.eclipse.jdt"; + private static final String PDE = "org.eclipse.pde"; + + /** Returns the MavenCentral groupId:artifactId appropriate for the given bundleId. */ + public static String groupIdArtifactId(String bundleId) { + if (bundleId.startsWith(JDT)) { + return JDT + ":" + bundleId; + } else if (bundleId.startsWith(PDE)) { + return PDE + ":" + bundleId; + } else { + return PLATFORM + ":" + bundleId; + } + } + + /** Creates a map from bundle-id to its corresponding 3-part version. */ + static Map parse(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException { + Map map = new HashMap<>(); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document doc = db.parse(inputStream); + Node artifacts = doc.getDocumentElement().getElementsByTagName("artifacts").item(0); + for (int i = 0; i < artifacts.getChildNodes().getLength(); ++i) { + Node artifact = artifacts.getChildNodes().item(i); + if ("artifact".equals(artifact.getNodeName())) { + String id = artifact.getAttributes().getNamedItem("id").getNodeValue(); + String version = artifact.getAttributes().getNamedItem("version").getNodeValue(); + Version parsed = Version.parseVersion(version); + map.put(id, parsed.getMajor() + "." + parsed.getMinor() + "." + parsed.getMicro()); + } + } + return map; + } + + private static final String ARTIFACTS_JAR = "artifacts.jar"; + + /** Returns a map from every bundle-id to its corresponding 3-part version (the qualifier is dropped). */ + public static Map bundleToVersion(EclipseRelease release) throws IOException { + // warn if the user is asking for a too-old version of eclipse, but go ahead and try anyway just in case + if (release.version().compareTo(FIRST_ON_CENTRAL.version()) < 0) { + System.err.println(FIRST_ON_CENTRAL.version() + " was the first eclipse release that was published on MavenCentral."); + } + File versionFolder = new File(GoomphCacheLocations.eclipseReleaseMetadata(), release.version().toString()); + versionFolder.mkdirs(); + File artifactsJar = new File(versionFolder, ARTIFACTS_JAR); + if (artifactsJar.exists() && artifactsJar.length() > 0) { + try { + return parseFromFile(artifactsJar); + } catch (Exception e) { + e.printStackTrace(); + System.err.println("Retrying download..."); + FileMisc.forceDelete(artifactsJar); + } + } + + byte[] content = Resources.toByteArray(new URL(release.updateSite() + "artifacts.jar")); + Files.write(content, artifactsJar); + return parseFromFile(artifactsJar); + } + + private static Map parseFromFile(File artifactsJar) throws IOException { + Box.Nullable> value = Box.Nullable.ofNull(); + ZipMisc.read(artifactsJar, "artifacts.xml", input -> { + value.set(Errors.rethrow().get(() -> parse(input))); + }); + return Objects.requireNonNull(value.get()); + } +} diff --git a/src/test/java/com/diffplug/gradle/eclipse/MavenCentralMappingTest.java b/src/test/java/com/diffplug/gradle/eclipse/MavenCentralMappingTest.java new file mode 100644 index 000000000..bfa7abf09 --- /dev/null +++ b/src/test/java/com/diffplug/gradle/eclipse/MavenCentralMappingTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2016 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.gradle.eclipse; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; + +import javax.xml.parsers.ParserConfigurationException; + +import org.assertj.core.api.Assertions; +import org.junit.Test; +import org.xml.sax.SAXException; + +import com.diffplug.gradle.pde.EclipseRelease; + +public class MavenCentralMappingTest { + @Test + public void testParsing() throws IOException, ParserConfigurationException, SAXException { + try (InputStream input = MavenCentralMappingTest.class.getResourceAsStream("/artifacts-4.6.3.xml")) { + assert463(MavenCentralMapping.parse(input)); + } + } + + @Test + public void testComplete() throws IOException { + assert463(MavenCentralMapping.bundleToVersion(EclipseRelease.official("4.6.3"))); + } + + private void assert463(Map bundleToVersion) { + Assertions.assertThat(bundleToVersion) + .containsEntry("org.eclipse.debug.core", "3.10.100") + .containsEntry("org.eclipse.equinox.p2.metadata", "2.3.100") + .hasSize(895); + } +} diff --git a/src/test/resources/artifacts-4.6.3.xml b/src/test/resources/artifacts-4.6.3.xml new file mode 100644 index 000000000..d5c988bf6 --- /dev/null +++ b/src/test/resources/artifacts-4.6.3.xml @@ -0,0 +1,16201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/placeholder b/src/test/resources/placeholder deleted file mode 100644 index e69de29bb..000000000 From 82ee931b1e3dcad15b19b31c158d87fc07fe0c3f Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 20 Mar 2018 13:25:54 -0700 Subject: [PATCH 3/6] Implemented the mavenCentral plugin. --- README.md | 3 +- build.gradle | 6 + .../gradle/eclipse/MavenCentralExtension.java | 116 ++++++++++++++++++ .../gradle/eclipse/MavenCentralMapping.java | 11 +- .../gradle/eclipse/MavenCentralPlugin.java | 79 ++++++++++++ .../java/com/diffplug/gradle/p2/P2Model.java | 4 +- ...lug.gradle.eclipse.mavencentral.properties | 1 + .../eclipse/MavenCentralPluginTest.java | 39 ++++++ 8 files changed, 252 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/diffplug/gradle/eclipse/MavenCentralExtension.java create mode 100644 src/main/java/com/diffplug/gradle/eclipse/MavenCentralPlugin.java create mode 100644 src/main/resources/META-INF/gradle-plugins/com.diffplug.gradle.eclipse.mavencentral.properties create mode 100644 src/test/java/com/diffplug/gradle/eclipse/MavenCentralPluginTest.java diff --git a/README.md b/README.md index 96c1b70d6..f68f922e1 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,9 @@ Below is an index of Goomph's capabilities, along with links to the javadoc wher * [`bndmanifest`](https://diffplug.github.io/goomph/javadoc/3.12.0/com/diffplug/gradle/osgi/BndManifestPlugin.html) generates a manifest using purely bnd, and outputs it for IDE consumption. * [`OsgiExecable`](https://diffplug.github.io/goomph/javadoc/3.12.0/com/diffplug/gradle/osgi/OsgiExecable.html) makes it easy to run a chunk of code within an OSGi container, and get the result from outside the container. -**`com.diffplug.gradle.eclipse` Plugins for creating and manipulating eclipse project files.** +**`com.diffplug.gradle.eclipse` Plugins for handling eclipse' maven central artifacts and creating and manipulating eclipse project files.** +* [`mavencentral`](https://diffplug.github.io/goomph/javadoc/3.12.0/com/diffplug/gradle/eclipse/MavenCentralPlugin.html) makes it easy to add dependency jars from an eclipse release. * [`buildproperties`](https://diffplug.github.io/goomph/javadoc/3.12.0/com/diffplug/gradle/eclipse/BuildPropertiesPlugin.html) uses [`build.properties`](http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Fguide%2Ftools%2Feditors%2Fmanifest_editor%2Fbuild.htm) to control a gradle build, and fixes eclipse project classpath to include binary assets specified in `build.properties`. * [`excludebuildfolder`](https://diffplug.github.io/goomph/javadoc/3.12.0/com/diffplug/gradle/eclipse/ExcludeBuildFolderPlugin.html) excludes the gradle `build` folder from Eclipse's resource indexing. * [`projectdeps`](https://diffplug.github.io/goomph/javadoc/3.12.0/com/diffplug/gradle/eclipse/ProjectDepsPlugin.html) fixes an intermittent problem where dependencies on other projects within the workspace aren't always resolved correctly within Eclipse. diff --git a/build.gradle b/build.gradle index d57c7f769..822386be8 100644 --- a/build.gradle +++ b/build.gradle @@ -314,6 +314,12 @@ pluginBundle { description = "Excludes the gradle build folder from Eclipse's resource indexing." tags = ['eclipse'] } + eclipseMavenCentralPlugin { + id = 'com.diffplug.gradle.eclipse.mavencentral' + displayName = 'Goomph eclipse.mavencentral' + description = 'Maps eclipse releases and bundle ids to their MavenCentral coordinates.' + tags = ['eclipse', 'mavenCentral'] + } eclipseProjectDepsPlugin { id = 'com.diffplug.gradle.eclipse.projectdeps' displayName = 'Goomph eclipse.projectdeps' diff --git a/src/main/java/com/diffplug/gradle/eclipse/MavenCentralExtension.java b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralExtension.java new file mode 100644 index 000000000..0a7cb55a4 --- /dev/null +++ b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralExtension.java @@ -0,0 +1,116 @@ +/* + * Copyright 2016 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.gradle.eclipse; + +import java.io.IOException; +import java.util.Map; +import java.util.Objects; + +import org.gradle.api.Action; +import org.gradle.api.Project; +import org.gradle.api.plugins.JavaPlugin; + +import com.diffplug.common.swt.os.SwtPlatform; +import com.diffplug.gradle.pde.EclipseRelease; + +public class MavenCentralExtension { + public static final String NAME = "eclipseMavenCentral"; + + private final Project project; + + public MavenCentralExtension(Project project) { + this.project = Objects.requireNonNull(project); + } + + public void release(String version, Action configurer) throws IOException { + release(EclipseRelease.official(version), configurer); + } + + public void release(EclipseRelease release, Action configurer) throws IOException { + configurer.execute(new ReleaseConfigurer(release)); + } + + public class ReleaseConfigurer { + final EclipseRelease release; + final Map bundleToVersion; + + public ReleaseConfigurer(EclipseRelease release) throws IOException { + this.release = release; + this.bundleToVersion = MavenCentralMapping.bundleToVersion(release); + } + + public void compileOnly(String bundleId) { + dep(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, bundleId); + } + + public void testCompileOnly(String bundleId) { + dep(JavaPlugin.TEST_COMPILE_ONLY_CONFIGURATION_NAME, bundleId); + } + + public void compile(String bundleId) { + dep(JavaPlugin.COMPILE_CONFIGURATION_NAME, bundleId); + } + + public void testCompile(String bundleId) { + dep(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME, bundleId); + } + + public void runtime(String bundleId) { + dep(JavaPlugin.RUNTIME_CONFIGURATION_NAME, bundleId); + } + + public void testRuntime(String bundleId) { + dep(JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME, bundleId); + } + + public void dep(String configName, String bundleId) { + String groupIdArtifactId = MavenCentralMapping.groupIdArtifactId(bundleId); + project.getDependencies().add(configName, groupIdArtifactId + ":" + bundleToVersion.get(bundleId)); + } + + ///////////// + // natives // + ///////////// + public void compileOnlyNative(String bundleId) { + nativeDep(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, bundleId); + } + + public void testCompileOnlyNative(String bundleId) { + nativeDep(JavaPlugin.TEST_COMPILE_ONLY_CONFIGURATION_NAME, bundleId); + } + + public void compileNative(String bundleId) { + nativeDep(JavaPlugin.COMPILE_CONFIGURATION_NAME, bundleId); + } + + public void testCompileNative(String bundleId) { + nativeDep(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME, bundleId); + } + + public void runtimeNative(String bundleId) { + nativeDep(JavaPlugin.RUNTIME_CONFIGURATION_NAME, bundleId); + } + + public void testRuntimeNative(String bundleId) { + nativeDep(JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME, bundleId); + } + + public void nativeDep(String configName, String bundleId) { + SwtPlatform platform = SwtPlatform.getRunning(); + dep(configName, bundleId + "." + platform); + } + } +} diff --git a/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java index 0939f4eb2..8b6c5abc9 100644 --- a/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java +++ b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java @@ -82,7 +82,7 @@ static Map parse(InputStream inputStream) throws ParserConfigura private static final String ARTIFACTS_JAR = "artifacts.jar"; /** Returns a map from every bundle-id to its corresponding 3-part version (the qualifier is dropped). */ - public static Map bundleToVersion(EclipseRelease release) throws IOException { + public static Map bundleToVersion(EclipseRelease release) { // warn if the user is asking for a too-old version of eclipse, but go ahead and try anyway just in case if (release.version().compareTo(FIRST_ON_CENTRAL.version()) < 0) { System.err.println(FIRST_ON_CENTRAL.version() + " was the first eclipse release that was published on MavenCentral."); @@ -99,10 +99,11 @@ public static Map bundleToVersion(EclipseRelease release) throws FileMisc.forceDelete(artifactsJar); } } - - byte[] content = Resources.toByteArray(new URL(release.updateSite() + "artifacts.jar")); - Files.write(content, artifactsJar); - return parseFromFile(artifactsJar); + return Errors.rethrow().get(() -> { + byte[] content = Resources.toByteArray(new URL(release.updateSite() + "artifacts.jar")); + Files.write(content, artifactsJar); + return parseFromFile(artifactsJar); + }); } private static Map parseFromFile(File artifactsJar) throws IOException { diff --git a/src/main/java/com/diffplug/gradle/eclipse/MavenCentralPlugin.java b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralPlugin.java new file mode 100644 index 000000000..db7f9a490 --- /dev/null +++ b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralPlugin.java @@ -0,0 +1,79 @@ +/* + * Copyright 2016 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.gradle.eclipse; + +import org.gradle.api.Project; +import org.gradle.api.plugins.JavaPlugin; + +import com.diffplug.gradle.ProjectPlugin; + +/** + * Now that Eclipse is publishing artifacts to maven central, + * it's possible to use the valuable components of the + * eclipse project without getting bogged down in p2 and OSGi. + * + * The trouble is that it can be difficult to get a coherent set + * of versions across the many bundles. It's also a little tricky + * to know what the groupId:artifactId mapping is, since eclipse + * artifacts only have a bundleId by default. + * + * Here is the fix: + * + * ``` + * eclipseMavenCentral { + * release '4.7.0', { + * compile 'org.eclipse.jdt' + * testCompile 'org.eclipse.jdt' + * dep 'compile', 'org.eclipse.jdt' + * } + * } + * ``` + * + * ## Platform-native jars + * + * If you want to add a specific jar to match the native + * system, there is a special `sourceSetNative` method, + * along with builtins like `testRuntimeNative` for each + * of the builtin java configurations. + * + * ``` + * eclipseMavenCentral { + * release '4.7.0', { + * testRuntimeNative 'org.eclipse.swt' + * nativeDep 'testRuntime', 'org.eclipse.swt' + * } + * } + * ``` + * + * Either of the above lines will add the + * `org.eclipse.swt.win32.win32.x86_64` as a `testRuntime` + * dependency if you're running on a 64-bit JVM on Windows, or some + * whichever platform-specific jar is appropriate. This + * works only for the SWT naming convention, `windowing.os.arch`. + * + * + * ## Compatibility + * + * Only works with versions from `4.6.2` onwards. + * + */ +public class MavenCentralPlugin extends ProjectPlugin { + @Override + protected void applyOnce(Project project) { + ProjectPlugin.getPlugin(project, JavaPlugin.class); + project.getExtensions().create(MavenCentralExtension.NAME, MavenCentralExtension.class, project); + } +} diff --git a/src/main/java/com/diffplug/gradle/p2/P2Model.java b/src/main/java/com/diffplug/gradle/p2/P2Model.java index e188bf6e0..2f6c53f07 100644 --- a/src/main/java/com/diffplug/gradle/p2/P2Model.java +++ b/src/main/java/com/diffplug/gradle/p2/P2Model.java @@ -297,7 +297,9 @@ private Node sourceNode(Node parent) { private Node slicingOptionsNode(Node parent) { Node slicingOptionsNode = new Node(parent, "slicingOptions"); for (Map.Entry option : slicingOptions.entrySet()) { - slicingOptionsNode.attributes().put(option.getKey(), option.getValue()); + @SuppressWarnings("unchecked") + Map attributes = slicingOptionsNode.attributes(); + attributes.put(option.getKey(), option.getValue()); } return slicingOptionsNode; } diff --git a/src/main/resources/META-INF/gradle-plugins/com.diffplug.gradle.eclipse.mavencentral.properties b/src/main/resources/META-INF/gradle-plugins/com.diffplug.gradle.eclipse.mavencentral.properties new file mode 100644 index 000000000..8ab479693 --- /dev/null +++ b/src/main/resources/META-INF/gradle-plugins/com.diffplug.gradle.eclipse.mavencentral.properties @@ -0,0 +1 @@ +implementation-class=com.diffplug.gradle.eclipse.MavenCentralPlugin diff --git a/src/test/java/com/diffplug/gradle/eclipse/MavenCentralPluginTest.java b/src/test/java/com/diffplug/gradle/eclipse/MavenCentralPluginTest.java new file mode 100644 index 000000000..904d614a3 --- /dev/null +++ b/src/test/java/com/diffplug/gradle/eclipse/MavenCentralPluginTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.gradle.eclipse; + +import java.io.IOException; + +import org.junit.Test; + +import com.diffplug.gradle.GradleIntegrationTest; + +public class MavenCentralPluginTest extends GradleIntegrationTest { + @Test + public void test() throws IOException { + write("build.gradle", + "plugins {", + " id 'com.diffplug.gradle.eclipse.mavencentral'", + "}", + "eclipseMavenCentral {", + " release '4.7.0', {", + " compile 'org.eclipse.equinox.common'", + " }", + "}", + "apply plugin: 'java'"); + gradleRunner().withArguments("jar", "--stacktrace").build(); + } +} From 2fa700f1bf8b0a793945520d28c7a958e3c98a0d Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 20 Mar 2018 14:24:26 -0700 Subject: [PATCH 4/6] Fix findbugs failure. --- .../java/com/diffplug/gradle/eclipse/MavenCentralMapping.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java index 8b6c5abc9..5f4cce438 100644 --- a/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java +++ b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java @@ -88,7 +88,7 @@ public static Map bundleToVersion(EclipseRelease release) { System.err.println(FIRST_ON_CENTRAL.version() + " was the first eclipse release that was published on MavenCentral."); } File versionFolder = new File(GoomphCacheLocations.eclipseReleaseMetadata(), release.version().toString()); - versionFolder.mkdirs(); + FileMisc.mkdirs(versionFolder); File artifactsJar = new File(versionFolder, ARTIFACTS_JAR); if (artifactsJar.exists() && artifactsJar.length() > 0) { try { From ab0ff5c076d373591d4747e3e16f1faa5a8f4adb Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 20 Mar 2018 14:24:34 -0700 Subject: [PATCH 5/6] Update changes. --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 776c94457..387c946fe 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,8 @@ ### Version 3.13.0-SNAPSHOT - TBD ([javadoc](http://diffplug.github.io/goomph/javadoc/snapshot/), [snapshot](https://oss.sonatype.org/content/repositories/snapshots/com/diffplug/gradle/goomph/)) +- Added support for translating eclipse releases to maven central coordinates. [(#61)](https://github.com/diffplug/goomph/pull/61) + ### Version 3.12.0 - February 26th 2018 ([javadoc](http://diffplug.github.io/goomph/javadoc/3.12.0/), [jcenter](https://bintray.com/diffplug/opensource/goomph/3.12.0/view)) - Added support for `includeLaunchers` property from product files [(#58)](https://github.com/diffplug/goomph/pull/58) From b2f5042868e88fb0e1b12a01bee4ff8324a96c87 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Tue, 20 Mar 2018 18:23:46 -0700 Subject: [PATCH 6/6] Add plugin id to docs. --- .../java/com/diffplug/gradle/eclipse/MavenCentralPlugin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/diffplug/gradle/eclipse/MavenCentralPlugin.java b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralPlugin.java index db7f9a490..d62d249e7 100644 --- a/src/main/java/com/diffplug/gradle/eclipse/MavenCentralPlugin.java +++ b/src/main/java/com/diffplug/gradle/eclipse/MavenCentralPlugin.java @@ -33,6 +33,7 @@ * Here is the fix: * * ``` + * apply plugin: 'com.diffplug.gradle.eclipse.mavencentral' * eclipseMavenCentral { * release '4.7.0', { * compile 'org.eclipse.jdt'