[ https://issues.apache.org/jira/browse/NETBEANS-127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16244040#comment-16244040 ]
ASF GitHub Bot commented on NETBEANS-127: ----------------------------------------- JaroslavTulach closed pull request #256: NETBEANS-127 use path to relativize file to root folder instead of regexp URL: https://github.com/apache/incubator-netbeans/pull/256 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/RatReportTask.java b/nbbuild/antsrc/org/netbeans/nbbuild/RatReportTask.java index 72b6b28a0..350757bfb 100644 --- a/nbbuild/antsrc/org/netbeans/nbbuild/RatReportTask.java +++ b/nbbuild/antsrc/org/netbeans/nbbuild/RatReportTask.java @@ -21,11 +21,11 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedHashMap; @@ -34,8 +34,6 @@ import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -129,7 +127,7 @@ public void execute() throws BuildException { simplfiedKey = simplfiedKey.replaceAll(".dir", ""); simplfiedKey = simplfiedKey.replaceAll(".depends", ""); clusterList.add(simplfiedKey); - modulebycluster.put(simplfiedKey, new HashSet<String>()); + modulebycluster.put(simplfiedKey, new HashSet<>()); } } for (String clusterName : clusterList) { @@ -212,7 +210,7 @@ private static String writeFiles(Set<String> listFile, String repo) { private void doPopulateUnapproved(Map<String, ModuleInfo> moduleRATInfo, Element rootElement, XPath path) throws XPathExpressionException { NodeList evaluate = (NodeList) path.evaluate("descendant::resource[license-approval/@name=\"false\"]", rootElement, XPathConstants.NODESET); for (int i = 0; i < evaluate.getLength(); i++) { - String resources = evaluate.item(i).getAttributes().getNamedItem("name").getTextContent().replaceFirst(root.getPath() + File.separator, ""); + String resources = relativize(evaluate.item(i).getAttributes().getNamedItem("name").getTextContent()); String moduleName = getModuleName(resources); if (!moduleRATInfo.containsKey(moduleName)) { moduleRATInfo.get(NOT_CLUSTER).addUnapproved(resources); @@ -225,7 +223,7 @@ private void doPopulateUnapproved(Map<String, ModuleInfo> moduleRATInfo, Element private void doPopulateApproved(Map<String, ModuleInfo> moduleRATInfo, Element rootElement, XPath path) throws XPathExpressionException { NodeList evaluate = (NodeList) path.evaluate("descendant::resource[license-approval/@name=\"true\"]", rootElement, XPathConstants.NODESET); for (int i = 0; i < evaluate.getLength(); i++) { - String resources = evaluate.item(i).getAttributes().getNamedItem("name").getTextContent().replaceFirst(root.getPath() + File.separator, ""); + String resources = relativize(evaluate.item(i).getAttributes().getNamedItem("name").getTextContent()); String moduleName = getModuleName(resources); if (!moduleRATInfo.containsKey(moduleName)) { moduleRATInfo.get(NOT_CLUSTER).addApproved(resources); @@ -236,6 +234,12 @@ private void doPopulateApproved(Map<String, ModuleInfo> moduleRATInfo, Element r } } + private String relativize(String target) { + Path full = Paths.get(target); + Path rootPath = root.toPath(); + return rootPath.relativize(full).toString(); + } + private String getModuleName(String resource) { String moduleName; if (!resource.contains(File.separator)) { ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Rat build doesn't work on Windows > --------------------------------- > > Key: NETBEANS-127 > URL: https://issues.apache.org/jira/browse/NETBEANS-127 > Project: NetBeans > Issue Type: Bug > Components: apisupport - Harness > Reporter: Jaroslav Tulach > Assignee: Eric Barboni > Priority: Critical > Labels: pull-request-available > > Looking at https://builds.apache.org/job/incubator-netbeans-windows/189 I see > a failure in {{RatReportTask}} I assume it is a result of > 162850d67436764aef5e5dd6016ca636d94921af > BUILD FAILED > f:\jenkins\jenkins-slave\workspace\incubator-netbeans-windows\nbbuild\build.xml:2179: > java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence > near index 3 > f:\jenkins\jenkins-slave\workspace\incubator-netbeans-windows\ > ^ > at java.util.regex.Pattern.error(Pattern.java:1955) > at java.util.regex.Pattern.escape(Pattern.java:2471) > at java.util.regex.Pattern.atom(Pattern.java:2198) > at java.util.regex.Pattern.sequence(Pattern.java:2130) > at java.util.regex.Pattern.expr(Pattern.java:1996) > at java.util.regex.Pattern.compile(Pattern.java:1696) > at java.util.regex.Pattern.<init>(Pattern.java:1351) > at java.util.regex.Pattern.compile(Pattern.java:1028) > at java.lang.String.replaceFirst(String.java:2178) > at > org.netbeans.nbbuild.RatReportTask.doPopulateUnapproved(RatReportTask.java:215) > at org.netbeans.nbbuild.RatReportTask.execute(RatReportTask.java:163) > at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) > at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) > at org.apache.tools.ant.Task.perform(Task.java:348) > at org.apache.tools.ant.Target.execute(Target.java:435) > at org.apache.tools.ant.Target.performTasks(Target.java:456) > at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405) > at org.apache.tools.ant.Project.executeTarget(Project.java:1376) > at > org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) > at org.apache.tools.ant.Project.executeTargets(Project.java:1260) > at org.apache.tools.ant.Main.runBuild(Main.java:854) > at org.apache.tools.ant.Main.startAnt(Main.java:236) > at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285) > at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112) -- This message was sent by Atlassian JIRA (v6.4.14#64029)