diff --git a/jetty-start/dependency-reduced-pom.xml b/jetty-start/dependency-reduced-pom.xml new file mode 100644 index 00000000000..e826dadab8e --- /dev/null +++ b/jetty-start/dependency-reduced-pom.xml @@ -0,0 +1,83 @@ + + + + jetty-project + org.eclipse.jetty + 9.3.1-SNAPSHOT + + 4.0.0 + jetty-start + Jetty :: Start + The start utility + http://www.eclipse.org/jetty + + + + maven-jar-plugin + + + + org.eclipse.jetty.start.Main + + + + + + org.codehaus.mojo + findbugs-maven-plugin + + org.eclipse.jetty.start.* + + + + maven-shade-plugin + 2.4 + + + package + + shade + + + + + true + + + org.eclipse.jetty:jetty-util + + + + + org.eclipse.jetty.util + org.eclipse.jetty.start.util + + + + + + + + + org.eclipse.jetty.toolchain + jetty-test-helper + 2.9 + test + + + junit + junit + + + hamcrest-library + org.hamcrest + + + + + + ${project.groupId}.start + start.jar + + + diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index d70800f7f99..b406b047252 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -32,9 +32,41 @@ org.eclipse.jetty.start.* + + org.apache.maven.plugins + maven-shade-plugin + 2.4 + + true + + + org.eclipse.jetty:jetty-util + + + + + org.eclipse.jetty.util + org.eclipse.jetty.start.util + + + + + + package + + shade + + + + + + org.eclipse.jetty + jetty-util + ${project.version} + org.eclipse.jetty.toolchain jetty-test-helper diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java index 14c372d0a7c..98b38bd2853 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java @@ -33,7 +33,7 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.eclipse.jetty.start.util.TopologicalSort; +import org.eclipse.jetty.util.TopologicalSort; /** * Access for all modules declared, as well as what is enabled. diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/util/TopologicalSort.java b/jetty-start/src/main/java/org/eclipse/jetty/start/util/TopologicalSort.java deleted file mode 100644 index 0c2d8b4244f..00000000000 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/util/TopologicalSort.java +++ /dev/null @@ -1,187 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. -// -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html -// -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php -// -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== -// - -package org.eclipse.jetty.start.util; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - - - -/** - * Topological Sort a list or array. - *

A Topological sort is used when you have a partial ordering expressed as - * dependencies between elements (also often represented as edges in a directed - * acyclic graph). A Topological sort should not be used when you have a total - * ordering expressed as a {@link Comparator} over the items. The algorithm has - * the additional characteristic that dependency sets are sorted by the original - * list order so that order is preserved when possible.

- *

- * The sort algorithm works by recursively visiting every item, once and - * only once. On each visit, the items dependencies are first visited and then the - * item is added to the sorted list. Thus the algorithm ensures that dependency - * items are always added before dependent items.

- *

- * THIS CLASS IS COPIED FROM org.eclipse.jetty.util.TopologicalSort - * @param The type to be sorted. It must be able to be added to a {@link HashSet} - */ -public class TopologicalSort -{ - private final Map> _dependencies = new HashMap<>(); - - /** - * Add a dependency to be considered in the sort. - * @param dependent The dependent item will be sorted after all its dependencies - * @param dependency The dependency item, will be sorted before its dependent item - */ - public void addDependency(T dependent, T dependency) - { - Set set = _dependencies.get(dependent); - if (set==null) - { - set=new HashSet<>(); - _dependencies.put(dependent,set); - } - set.add(dependency); - } - - /** Sort the passed array according to dependencies previously set with - * {@link #addDependency(Object, Object)}. Where possible, ordering will be - * preserved if no dependency - * @param array The array to be sorted. - */ - public void sort(T[] array) - { - List sorted = new ArrayList<>(); - Set visited = new HashSet<>(); - Comparator comparator = new InitialOrderComparitor<>(array); - - // Visit all items in the array - for (T t : array) - visit(t,visited,sorted,comparator); - - sorted.toArray(array); - } - - /** Sort the passed list according to dependencies previously set with - * {@link #addDependency(Object, Object)}. Where possible, ordering will be - * preserved if no dependency - * @param list The list to be sorted. - */ - public void sort(Collection list) - { - List sorted = new ArrayList<>(); - Set visited = new HashSet<>(); - Comparator comparator = new InitialOrderComparitor<>(list); - - // Visit all items in the list - for (T t : list) - visit(t,visited,sorted,comparator); - - list.clear(); - list.addAll(sorted); - } - - /** Visit an item to be sorted. - * @param item The item to be visited - * @param visited The Set of items already visited - * @param sorted The list to sort items into - * @param comparator A comparator used to sort dependencies. - */ - private void visit(T item, Set visited, List sorted,Comparator comparator) - { - // If the item has not been visited - if(!visited.contains(item)) - { - // We are visiting it now, so add it to the visited set - visited.add(item); - - // Lookup the items dependencies - Set dependencies = _dependencies.get(item); - if (dependencies!=null) - { - // Sort the dependencies - SortedSet ordered_deps = new TreeSet<>(comparator); - ordered_deps.addAll(dependencies); - - // recursively visit each dependency - for (T d:ordered_deps) - visit(d,visited,sorted,comparator); - } - - // Now that we have visited all our dependencies, they and their - // dependencies will have been added to the sorted list. So we can - // now add the current item and it will be after its dependencies - sorted.add(item); - } - else if (!sorted.contains(item)) - // If we have already visited an item, but it has not yet been put in the - // sorted list, then we must be in a cycle! - throw new IllegalStateException("cyclic at "+item); - } - - - /** A comparator that is used to sort dependencies in the order they - * were in the original list. This ensures that dependencies are visited - * in the original order and no needless reordering takes place. - * @param - */ - private static class InitialOrderComparitor implements Comparator - { - private final Map _indexes = new HashMap<>(); - InitialOrderComparitor(T[] initial) - { - int i=0; - for (T t : initial) - _indexes.put(t,i++); - } - - InitialOrderComparitor(Collection initial) - { - int i=0; - for (T t : initial) - _indexes.put(t,i++); - } - - @Override - public int compare(T o1, T o2) - { - Integer i1=_indexes.get(o1); - Integer i2=_indexes.get(o2); - if (i1==null || i2==null || i1.equals(o2)) - return 0; - if (i1A Topological sort is used when you have a partial ordering expressed as * dependencies between elements (also often represented as edges in a directed * acyclic graph). A Topological sort should not be used when you have a total @@ -75,7 +74,7 @@ public class TopologicalSort { List sorted = new ArrayList<>(); Set visited = new HashSet<>(); - Comparator comparator = new InitialOrderComparitor<>(array); + Comparator comparator = new InitialOrderComparator<>(array); // Visit all items in the array for (T t : array) @@ -93,7 +92,7 @@ public class TopologicalSort { List sorted = new ArrayList<>(); Set visited = new HashSet<>(); - Comparator comparator = new InitialOrderComparitor<>(list); + Comparator comparator = new InitialOrderComparator<>(list); // Visit all items in the list for (T t : list) @@ -147,17 +146,17 @@ public class TopologicalSort * in the original order and no needless reordering takes place. * @param */ - private static class InitialOrderComparitor implements Comparator + private static class InitialOrderComparator implements Comparator { private final Map _indexes = new HashMap<>(); - InitialOrderComparitor(T[] initial) + InitialOrderComparator(T[] initial) { int i=0; for (T t : initial) _indexes.put(t,i++); } - InitialOrderComparitor(Collection initial) + InitialOrderComparator(Collection initial) { int i=0; for (T t : initial)