Skip to content

Commit

Permalink
Merge pull request #3600 from Rawi01/eclipse-dependency-download-with…
Browse files Browse the repository at this point in the history
…-version-support

Fix broken eclipse-I tasks
  • Loading branch information
Rawi01 authored Feb 2, 2024
2 parents 1eae01f + de4f602 commit f3a4b1b
Show file tree
Hide file tree
Showing 15 changed files with 434 additions and 85 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/ant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -140,15 +140,15 @@ jobs:
- name: Cache base testenv
if: ${{ !endsWith(matrix.version, 'full') }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
testenv
key: base-testenv-${{ hashFiles('**/setup.ant.xml') }}

- name: Cache full testenv
if: ${{ endsWith(matrix.version, 'full') }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
testenv
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions buildScripts/setup.ant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
21 changes: 0 additions & 21 deletions src/support/lombok/eclipse/dependencies/UniqueQueue.java

This file was deleted.

79 changes: 45 additions & 34 deletions src/support/lombok/eclipse/dependencies/UpdateSite.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
/*
* 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;
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;
Expand All @@ -25,10 +44,10 @@
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();
Expand All @@ -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);
Expand Down Expand Up @@ -72,15 +89,7 @@ public void read(String url) throws Exception {

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) {
Expand All @@ -92,48 +101,50 @@ public Set<String> resolveWithDependencies(List<String> dependencies) {
}

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) {
for (Required required : unit.requires) {
if (required.optional) continue;
if (!matchesFilter(required.filter)) continue;

toResolve.add(required.namespace + ":" + required.name);
toResolve.add(required);
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/support/lombok/eclipse/dependencies/model/Child.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
30 changes: 29 additions & 1 deletion src/support/lombok/eclipse/dependencies/model/Provided.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
/*
* 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
public String namespace;
@XmlAttribute
public String name;
@XmlAttribute
public String version;
@XmlJavaTypeAdapter(VersionAdapter.class)
public Version version;

@Override
public String toString() {
return namespace + ":" + name + "_" + version;
}
}
Loading

0 comments on commit f3a4b1b

Please sign in to comment.