You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/06/15 21:43:14 UTC

[GitHub] [netbeans] mbien commented on a diff in pull request #4194: Try to generate maven project skeleton from our dependencies

mbien commented on code in PR #4194:
URL: https://github.com/apache/netbeans/pull/4194#discussion_r898457667


##########
nbbuild/antsrc/org/netbeans/nbbuild/extlibs/MavenSkeletonProject.java:
##########
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.nbbuild.extlibs;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * Task to check that external libraries have legitimate licenses, etc.
+ */
+public class MavenSkeletonProject extends Task {
+
+    private File nball;
+
+    public void setNball(File nball) {
+        this.nball = nball;
+    }
+
+    private File mavenfolderFile;
+
+    /**
+     * JUnit-format XML result file to generate, rather than halting the build.
+     */
+    public void setMavenFolder(File report) {
+        this.mavenfolderFile = report;
+    }
+
+    private Set<String> modules;
+
+    public @Override
+    void execute() throws BuildException {
+        try { // XXX workaround for http://issues.apache.org/bugzilla/show_bug.cgi?id=43398
+            if (getProject().getProperty("allmodules") != null) {
+                modules = new TreeSet<>(Arrays.asList(getProject().getProperty("allmodules").split("[, ]+")));
+                modules.add("nbbuild");
+            } else {
+                Path nbAllPath = nball.toPath();
+                modules = new TreeSet<>(
+                        Files.walk(nbAllPath)

Review Comment:
   most of the streams which are returned from `Files.*` must be closed after use. Would be good to wrap the stream in an arm-block and do the rest in the block.
   
   I have some jackpot rules here (since its easy to forget - most streams don't have to be closed):
   https://github.com/mbien/jackpot-inspections/blob/5b518358408dda4008be5b7f2602aa3304a0c8fc/ProbableBugs.hint#L32-L40



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists