Skip to content

Commit f835c93

Browse files
authored
Consider only artifacts with "osgi.bundle" classifier (#156 fixes #155)
2 parents f1d8086 + 6c5bfaf commit f835c93

File tree

4 files changed

+19553
-8
lines changed

4 files changed

+19553
-8
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
- Fix version parsing in eclipseMavenCentral ([#156](https://github.com/diffplug/goomph/pull/156))
7+
58
## [3.32.0] - 2021-09-03
69
### Added
710
- New plugin `com.diffplug.configuration-cache-for-platform-specific-build` which makes the `OS.getNative()` and `SwtPlatform.xxx` methods work without breaking the Gradle configuration cache. ([#153](https://github.com/diffplug/goomph/pull/153))

src/main/java/com/diffplug/gradle/eclipse/MavenCentralMapping.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class MavenCentralMapping {
4444
private static final String JDT = "org.eclipse.jdt";
4545
private static final String PDE = "org.eclipse.pde";
4646
private static final String EMF = "org.eclipse.emf";
47-
47+
4848
public static boolean isEclipseGroup(String group) {
4949
return group.equals(PLATFORM) || group.equals(JDT) || group.equals(PDE) || group.equals(EMF);
5050
}
@@ -72,10 +72,13 @@ static Map<String, String> parse(InputStream inputStream) throws ParserConfigura
7272
for (int i = 0; i < artifacts.getChildNodes().getLength(); ++i) {
7373
Node artifact = artifacts.getChildNodes().item(i);
7474
if ("artifact".equals(artifact.getNodeName())) {
75-
String id = artifact.getAttributes().getNamedItem("id").getNodeValue();
76-
String version = artifact.getAttributes().getNamedItem("version").getNodeValue();
77-
Version parsed = Version.parseVersion(version);
78-
map.put(id, parsed.getMajor() + "." + parsed.getMinor() + "." + parsed.getMicro());
75+
String classifier = artifact.getAttributes().getNamedItem("classifier").getNodeValue();
76+
if ("osgi.bundle".equals(classifier)) {
77+
String id = artifact.getAttributes().getNamedItem("id").getNodeValue();
78+
String version = artifact.getAttributes().getNamedItem("version").getNodeValue();
79+
Version parsed = Version.parseVersion(version);
80+
map.put(id, parsed.getMajor() + "." + parsed.getMinor() + "." + parsed.getMicro());
81+
}
7982
}
8083
}
8184
return map;

src/test/java/com/diffplug/gradle/eclipse/MavenCentralMappingTest.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015-2020 DiffPlug
2+
* Copyright (C) 2015-2021 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@
2727

2828
public class MavenCentralMappingTest {
2929
@Test
30-
public void testParsing() throws IOException, ParserConfigurationException, SAXException {
30+
public void testParsing463() throws IOException, ParserConfigurationException, SAXException {
3131
try (InputStream input = MavenCentralMappingTest.class.getResourceAsStream("/artifacts-4.6.3.xml")) {
3232
assert463(MavenCentralMapping.parse(input));
3333
}
@@ -42,7 +42,23 @@ private void assert463(Map<String, String> bundleToVersion) {
4242
Assertions.assertThat(bundleToVersion)
4343
.containsEntry("org.eclipse.debug.core", "3.10.100")
4444
.containsEntry("org.eclipse.equinox.p2.metadata", "2.3.100")
45-
.hasSize(895);
45+
.containsEntry("org.eclipse.help", "3.7.0")
46+
.hasSize(743);
47+
}
48+
49+
@Test
50+
public void testParsing4140() throws IOException, ParserConfigurationException, SAXException {
51+
try (InputStream input = MavenCentralMappingTest.class.getResourceAsStream("/artifacts-4.14.0.xml")) {
52+
assert4140(MavenCentralMapping.parse(input));
53+
}
54+
}
55+
56+
private void assert4140(Map<String, String> bundleToVersion) {
57+
Assertions.assertThat(bundleToVersion)
58+
.containsEntry("org.eclipse.debug.core", "3.14.100")
59+
.containsEntry("org.eclipse.equinox.p2.metadata", "2.4.600")
60+
.containsEntry("org.eclipse.help", "3.8.600")
61+
.hasSize(785);
4662
}
4763

4864
@Test

0 commit comments

Comments
 (0)