make alldependencies element work - fixes #304

Fri, 22 Sep 2023 22:30:18 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 22 Sep 2023 22:30:18 +0200
changeset 74
30b70a68ad26
parent 73
5d84da6be928
child 75
b49869bd2a0a

make alldependencies element work - fixes #304

src/main/java/de/unixwork/uwproj/Project.java file | annotate | diff | comparison | revisions
src/main/java/de/unixwork/uwproj/Target.java file | annotate | diff | comparison | revisions
--- a/src/main/java/de/unixwork/uwproj/Project.java	Fri Sep 22 22:28:44 2023 +0200
+++ b/src/main/java/de/unixwork/uwproj/Project.java	Fri Sep 22 22:30:18 2023 +0200
@@ -63,6 +63,12 @@
             namedDependencies.values().stream().flatMap(Collection::stream),
             dependencies.stream()
         ).flatMap(d -> d.getLang().stream()).collect(Collectors.toSet());
+
+        // check if some targets want all named dependencies
+        targets.stream().filter(Target::isAllDependencies).forEach(t -> {
+            t.clearDependencies();
+            namedDependencies.keySet().forEach(t::addDependency);
+        });
     }
 
     private void createDefaultTarget() {
--- a/src/main/java/de/unixwork/uwproj/Target.java	Fri Sep 22 22:28:44 2023 +0200
+++ b/src/main/java/de/unixwork/uwproj/Target.java	Fri Sep 22 22:30:18 2023 +0200
@@ -16,7 +16,6 @@
     private String prefix;
 
     private final List<String> dependencies = new LinkedList<>();
-    private final List<String> optionalDependencies = new LinkedList<>();
     private final List<Define> defines = new LinkedList<>();
     private final List<Feature> features = new LinkedList<>();
     private final List<Option> options = new LinkedList<>();
@@ -97,26 +96,18 @@
         return withPrefix("CXXFLAGS");
     }
 
+    public void clearDependencies() {
+        dependencies.clear();
+    }
+
     public List<String> getDependencies() {
         return dependencies;
     }
 
-    public void addDependency(String dependency, boolean optional) {
-        if (optional) {
-            optionalDependencies.add(dependency);
-        } else {
-            dependencies.add(dependency);
-        }
-    }
-
     public void addDependency(String dependency) {
         dependencies.add(dependency);
     }
 
-    public List<String> getOptionalDependencies() {
-        return optionalDependencies;
-    }
-
     public boolean isAllDependencies() {
         return allDependencies;
     }

mercurial