mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 20:17:25 +00:00
Merge pull request #3600 from Rawi01/eclipse-dependency-download-with-version-support
Fix broken eclipse-I tasks
This commit is contained in:
15 files changed
+434
-85
No files matched your search
+14
-14
@@ -10,16 +10,16 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: 11
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
ivyCache
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
- name: Build with Ant
|
||||
run: ant -noinput dist
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: lombok.jar
|
||||
path: dist/lombok.jar
|
||||
@@ -55,11 +55,11 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK ${{ matrix.jdk }}
|
||||
if: ${{ matrix.jdk < env.EA_JDK }}
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: ${{ matrix.jdk }}
|
||||
distribution: 'zulu'
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
echo "${HOME}/apache-ant-$ANT_VERSION/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
ivyCache
|
||||
@@ -120,16 +120,16 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: 'zulu'
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
ivyCache
|
||||
@@ -140,7 +140,7 @@ jobs:
|
||||
|
||||
- name: Cache base testenv
|
||||
if: ${{ !endsWith(matrix.version, 'full') }}
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
testenv
|
||||
@@ -148,7 +148,7 @@ jobs:
|
||||
|
||||
- name: Cache full testenv
|
||||
if: ${{ endsWith(matrix.version, 'full') }}
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
testenv
|
||||
@@ -176,9 +176,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: lombok.jar
|
||||
|
||||
|
||||
@@ -202,11 +202,9 @@ This buildfile is part of projectlombok.org. It sets up the build itself.
|
||||
<sequential>
|
||||
<fetchdep.eclipse.updatesite name="@{name}" version="@{version}">
|
||||
<bundles>
|
||||
<!-- Ambiguous + osgi.extender dependecies -->
|
||||
<arg value="osgi.bundle:javax.el-api" />
|
||||
<!-- osgi.extender dependecies -->
|
||||
<arg value="osgi.bundle:org.apache.felix.scr" />
|
||||
<arg value="osgi.bundle:org.apache.aries.spifly.dynamic.bundle" />
|
||||
<arg value="osgi.bundle:org.apache.commons.commons-io" />
|
||||
<!-- Real dependencies -->
|
||||
<arg value="osgi.bundle:org.eclipse.jdt.core" />
|
||||
<arg value="osgi.bundle:org.eclipse.jdt.ui" />
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package lombok.eclipse.dependencies;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An incomplete implementation of a queue that maintains a history of all queued items and ensures unique elements.
|
||||
* Elements cannot be added to the queue if they already exist in the history.
|
||||
*/
|
||||
public class UniqueQueue<T> extends ArrayDeque<T> {
|
||||
private Set<T> added = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public boolean add(T e) {
|
||||
if (added.add(e)) {
|
||||
return super.add(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
@@ -5,11 +26,9 @@ import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -25,10 +44,10 @@ import javax.xml.transform.sax.SAXSource;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import lombok.eclipse.dependencies.model.Child;
|
||||
import lombok.eclipse.dependencies.model.Provided;
|
||||
import lombok.eclipse.dependencies.model.Repository;
|
||||
import lombok.eclipse.dependencies.model.Required;
|
||||
import lombok.eclipse.dependencies.model.Unit;
|
||||
import lombok.eclipse.dependencies.model.VersionRange;
|
||||
|
||||
public class UpdateSite {
|
||||
private static final String OS_NAME = System.getProperty("os.name").toLowerCase();
|
||||
@@ -38,13 +57,11 @@ public class UpdateSite {
|
||||
|
||||
private JAXBContext jaxbContext;
|
||||
private Repository repository;
|
||||
private Map<String, List<Unit>> providesIndex;
|
||||
private String resolvedUrl;
|
||||
private SAXParserFactory saxParserFactory;
|
||||
|
||||
public UpdateSite() throws Exception {
|
||||
jaxbContext = JAXBContext.newInstance(Repository.class);
|
||||
providesIndex = new HashMap<>();
|
||||
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
spf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
@@ -72,15 +89,7 @@ public class UpdateSite {
|
||||
|
||||
try (InputStream inputStream = readJarOrXml(resolvedUrl, "content")) {
|
||||
repository = unmarshalRepository(inputStream);
|
||||
|
||||
// Build index
|
||||
for (Unit unit : repository.units) {
|
||||
for (Provided provides : unit.provides) {
|
||||
providesIndex.computeIfAbsent(provides.namespace + ":" + provides.name, k -> new ArrayList<>()).add(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
public Set<String> resolveWithoutDependencies(List<String> dependencies) {
|
||||
@@ -92,40 +101,42 @@ public class UpdateSite {
|
||||
}
|
||||
|
||||
private Set<String> resolve(List<String> dependencies, boolean withDependencies) {
|
||||
Queue<String> toResolve = new UniqueQueue<>();
|
||||
Queue<Required> toResolve = new ArrayDeque<>();
|
||||
for (String dependency : dependencies) {
|
||||
toResolve.add(dependency);
|
||||
String[] split = dependency.split(":");
|
||||
Required required = new Required();
|
||||
required.namespace = split[0];
|
||||
required.name = split[1];
|
||||
required.range = VersionRange.ALL;
|
||||
toResolve.add(required);
|
||||
}
|
||||
Set<Unit> resolved = new HashSet<>();
|
||||
while (!toResolve.isEmpty()) {
|
||||
String next = toResolve.poll();
|
||||
Required next = toResolve.poll();
|
||||
|
||||
List<Unit> providedUnits = providesIndex.get(next);
|
||||
// Skip already resolved
|
||||
if (resolved.stream().anyMatch(u -> u.satisfies(next))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Unit> satisfyingUnits = repository.units.stream().filter(u -> u.satisfies(next)).collect(Collectors.toList());
|
||||
// Skip unknown
|
||||
if (providedUnits == null) {
|
||||
if (satisfyingUnits.isEmpty()) {
|
||||
System.out.println("Skipping unknown unit " + next);
|
||||
continue;
|
||||
}
|
||||
// Remove a.jre.javase dependency
|
||||
List<Unit> filteredProvidedUnits = providedUnits.stream()
|
||||
.filter(u -> !u.id.equals("a.jre.javase")) // Remove
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (filteredProvidedUnits.size() == 0) {
|
||||
// This is a JDK only dependency, skip
|
||||
// Skip JDK dependencies
|
||||
boolean jdkDependency = satisfyingUnits.stream().anyMatch(u -> u.id.equals("a.jre.javase"));
|
||||
if (jdkDependency) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip ambiguous (we could use version ranges to solve that...)
|
||||
if (filteredProvidedUnits.size() > 1) {
|
||||
boolean alreadyResolved = filteredProvidedUnits.stream().anyMatch(resolved::contains);
|
||||
if (!alreadyResolved) {
|
||||
System.out.println("Ambiguous resolution for " + next + ": " + filteredProvidedUnits.toString());
|
||||
continue;
|
||||
}
|
||||
if (satisfyingUnits.size() > 1) {
|
||||
System.out.println("Ambiguous resolution for " + next + ": " + satisfyingUnits.toString() + ", picking first");
|
||||
}
|
||||
|
||||
Unit unit = filteredProvidedUnits.get(0);
|
||||
Unit unit = satisfyingUnits.get(0);
|
||||
resolved.add(unit);
|
||||
|
||||
if (withDependencies && unit.requires != null) {
|
||||
@@ -133,7 +144,7 @@ public class UpdateSite {
|
||||
if (required.optional) continue;
|
||||
if (!matchesFilter(required.filter)) continue;
|
||||
|
||||
toResolve.add(required.namespace + ":" + required.name);
|
||||
toResolve.add(required);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
public class Provided {
|
||||
@XmlAttribute
|
||||
@@ -8,5 +30,11 @@ public class Provided {
|
||||
@XmlAttribute
|
||||
public String name;
|
||||
@XmlAttribute
|
||||
public String version;
|
||||
@XmlJavaTypeAdapter(VersionAdapter.class)
|
||||
public Version version;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return namespace + ":" + name + "_" + version;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
public class Required {
|
||||
@XmlAttribute
|
||||
@@ -9,9 +31,15 @@ public class Required {
|
||||
@XmlAttribute
|
||||
public String name;
|
||||
@XmlAttribute
|
||||
public String range;
|
||||
@XmlJavaTypeAdapter(VersionRangeAdapter.class)
|
||||
public VersionRange range;
|
||||
@XmlAttribute
|
||||
public boolean optional;
|
||||
@XmlElement
|
||||
public String filter;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return namespace + ":" + name + "_" + range;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies.model;
|
||||
|
||||
import java.util.List;
|
||||
@@ -5,12 +26,14 @@ import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
public class Unit {
|
||||
@XmlAttribute
|
||||
public String id;
|
||||
@XmlAttribute
|
||||
public String version;
|
||||
@XmlJavaTypeAdapter(VersionAdapter.class)
|
||||
public Version version;
|
||||
|
||||
@XmlElementWrapper(name = "provides")
|
||||
@XmlElement(name="provided")
|
||||
@@ -19,7 +42,11 @@ public class Unit {
|
||||
@XmlElementWrapper(name = "requires")
|
||||
@XmlElement(name="required")
|
||||
public List<Required> requires;
|
||||
|
||||
|
||||
public boolean satisfies(Required required) {
|
||||
return provides.stream().anyMatch(p -> p.namespace.equals(required.namespace) && p.name.equals(required.name) && required.range.contains(p.version));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id + "_" + version;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies.model;
|
||||
|
||||
public class Version {
|
||||
private int major;
|
||||
private int minor;
|
||||
private int micro;
|
||||
private String qualifier = "";
|
||||
|
||||
public static Version parse(String v) {
|
||||
String[] parts = v.split("\\.", 4);
|
||||
|
||||
Version version = new Version();
|
||||
version.major = Integer.parseInt(parts[0]);
|
||||
if (parts.length > 1) {
|
||||
version.minor = Integer.parseInt(parts[1]);
|
||||
}
|
||||
if (parts.length > 2) {
|
||||
version.micro = Integer.parseInt(parts[2]);
|
||||
}
|
||||
if (parts.length > 3) {
|
||||
version.qualifier = parts[3];
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
public int compareTo(Version other) {
|
||||
int result = major - other.major;
|
||||
if (result != 0) return result;
|
||||
|
||||
result = minor - other.minor;
|
||||
if (result != 0) return result;
|
||||
|
||||
result = micro - other.micro;
|
||||
if (result != 0) return result;
|
||||
|
||||
return qualifier.compareTo(other.qualifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String result = major + "." + minor + "." + micro;
|
||||
if (!qualifier.isEmpty()) result += "." + qualifier;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies.model;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
public class VersionAdapter extends XmlAdapter<String, Version> {
|
||||
|
||||
@Override
|
||||
public Version unmarshal(String v) throws Exception {
|
||||
return Version.parse(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marshal(Version v) throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies.model;
|
||||
|
||||
public class VersionRange {
|
||||
public static final VersionRange ALL = VersionRange.parse("0.0.0");
|
||||
|
||||
private Version min;
|
||||
private Version max;
|
||||
private boolean leftInclusive;
|
||||
private boolean leftExclusive;
|
||||
private boolean rightInclusive;
|
||||
private boolean rightExclusive;
|
||||
|
||||
public static VersionRange parse(String v) {
|
||||
VersionRange versionRange = new VersionRange();
|
||||
versionRange.leftInclusive = v.startsWith("[");
|
||||
versionRange.leftExclusive = v.startsWith("(");
|
||||
versionRange.rightInclusive = v.endsWith("]");
|
||||
versionRange.rightExclusive = v.endsWith(")");
|
||||
|
||||
if (!versionRange.leftInclusive && !versionRange.leftExclusive) {
|
||||
Version version = Version.parse(v);
|
||||
versionRange.min = version;
|
||||
versionRange.leftInclusive = true;
|
||||
return versionRange;
|
||||
}
|
||||
|
||||
String[] parts = v.replaceAll("[\\[\\(\\)\\]]", "").split(",");
|
||||
versionRange.min = Version.parse(parts[0]);
|
||||
versionRange.max = Version.parse(parts[1]);
|
||||
return versionRange;
|
||||
}
|
||||
|
||||
public boolean contains(Version version) {
|
||||
if (min != null) {
|
||||
int result = min.compareTo(version);
|
||||
if (result > 0) return false;
|
||||
if (result == 0 && !leftInclusive) return false;
|
||||
}
|
||||
if (max != null) {
|
||||
int result = max.compareTo(version);
|
||||
if (result < 0) return false;
|
||||
if (result == 0 && !rightInclusive) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (leftInclusive) sb.append("[");
|
||||
if (leftExclusive) sb.append("(");
|
||||
if (min != null) sb.append(min);
|
||||
sb.append(",");
|
||||
if (max != null) sb.append(max);
|
||||
if (rightInclusive) sb.append("]");
|
||||
if (rightExclusive) sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.eclipse.dependencies.model;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
public class VersionRangeAdapter extends XmlAdapter<String, VersionRange> {
|
||||
|
||||
@Override
|
||||
public VersionRange unmarshal(String v) throws Exception {
|
||||
return VersionRange.parse(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marshal(VersionRange v) throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,6 +52,7 @@ import org.eclipse.jdt.internal.compiler.batch.FileSystem;
|
||||
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
|
||||
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
|
||||
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
|
||||
import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner;
|
||||
import org.eclipse.jdt.internal.core.JavaModelManager;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
@@ -308,7 +309,7 @@ public class RunTestsViaEcj extends AbstractRunTests {
|
||||
private final char[] mainTypeName;
|
||||
|
||||
private TestCompilationUnitEclipse(String name, String source) {
|
||||
super(null, name, null);
|
||||
super(null, name, DefaultWorkingCopyOwner.PRIMARY);
|
||||
this.source = source.toCharArray();
|
||||
|
||||
char[] fileNameCharArray = getFileName();
|
||||
@@ -320,14 +321,6 @@ public class RunTestsViaEcj extends AbstractRunTests {
|
||||
mainTypeName = CharOperation.subarray(fileNameCharArray, start, end);
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return System.identityHashCode(this);
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
}
|
||||
|
||||
@Override public char[] getContents() {
|
||||
return source;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user