geertjanw closed pull request #2: add maven plugin to generate report crosscheck jenkins / confluence URL: https://github.com/apache/incubator-netbeans-tools/pull/2
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/.gitignore b/.gitignore index f4a9236..f0c696d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /convert/nbproject/private/ /convert/build/ -/convert/dist/ \ No newline at end of file +/convert/dist/ +/target/** \ No newline at end of file diff --git a/licencereviewsite/nb-configuration.xml b/licencereviewsite/nb-configuration.xml new file mode 100644 index 0000000..f671692 --- /dev/null +++ b/licencereviewsite/nb-configuration.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project-shared-configuration> + <!-- + This file contains additional configuration written by modules in the NetBeans IDE. + The configuration is intended to be shared among all the users of project and + therefore it is assumed to be part of version control checkout. + Without this configuration present, some functionality in the IDE may be limited or fail altogether. + --> + <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"> + <!-- + Properties that influence various parts of the IDE, especially code formatting and the like. + You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up. + That way multiple projects can share the same settings (useful for formatting rules for example). + Any value defined here will override the pom.xml file value but is only applicable to the current project. + --> + <netbeans.hint.license>apache20</netbeans.hint.license> + </properties> +</project-shared-configuration> diff --git a/licencereviewsite/nbactions.xml b/licencereviewsite/nbactions.xml new file mode 100644 index 0000000..2a22f43 --- /dev/null +++ b/licencereviewsite/nbactions.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<actions> + <action> + <actionName>CUSTOM-generate</actionName> + <displayName>generate</displayName> + <goals> + <goal>clean</goal> + <goal>install</goal> + <goal>site</goal> + + </goals> + </action> +</actions> diff --git a/licencereviewsite/pom.xml b/licencereviewsite/pom.xml new file mode 100644 index 0000000..3245573 --- /dev/null +++ b/licencereviewsite/pom.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.netbeans</groupId> + <artifactId>generatereviewstatuspage</artifactId> + <version>1.1-SNAPSHOT</version> + <packaging>maven-plugin</packaging> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + </properties> + <dependencies> + <dependency> + <!-- jsoup HTML parser library @ https://jsoup.org/ --> + <groupId>org.jsoup</groupId> + <artifactId>jsoup</artifactId> + <version>1.10.3</version> + </dependency> + <dependency> + <groupId>org.apache.maven.reporting</groupId> + <artifactId>maven-reporting-impl</artifactId> + <version>3.0.0</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>3.5.2</version> + </dependency> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + <version>3.5</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <version>3.6</version> + </plugin> + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <version>0.12</version> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + <reporting> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>2.9</version> + <reportSets> + <reportSet> + <reports> + <report>index</report> + </reports> + <!-- <configuration> + <skip>true</skip> + </configuration>--> + </reportSet> + </reportSets> + </plugin> + <!-- any further custom report here --> + <plugin> + <groupId>${project.groupId}</groupId> + <artifactId>generatereviewstatuspage</artifactId> + <version>${project.version}</version> + </plugin> + </plugins> + </reporting> +</project> \ No newline at end of file diff --git a/licencereviewsite/src/main/java/org/apache/netbeans/generatestatus/GenerateLicencePage.java b/licencereviewsite/src/main/java/org/apache/netbeans/generatestatus/GenerateLicencePage.java new file mode 100644 index 0000000..fa6f522 --- /dev/null +++ b/licencereviewsite/src/main/java/org/apache/netbeans/generatestatus/GenerateLicencePage.java @@ -0,0 +1,131 @@ +/* + * + * Licensed 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.apache.netbeans.generatestatus; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.reporting.AbstractMavenReport; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +/** + * + * @author skygo + */ +@Mojo(name = "checklicence") +public class GenerateLicencePage extends AbstractMavenReport { + + @Override + protected void executeReport(Locale locale) throws MavenReportException { + try { + prepareReport("unapproved license"); + } catch (IOException ex) { + throw new MavenReportException("error", ex); + } + } + + @Override + public String getOutputName() { + return "reviewlicence"; + } + + @Override + public String getName(Locale locale) { + return "Apache NetBeans Licence Checking"; + } + + @Override + public String getDescription(Locale locale) { + return "NetBeans review"; + } + Map<String, Element> links = new HashMap<>(); + + private void prepareReport(String pattern) throws IOException { + Document jenkinsresults = Jsoup.connect("https://builds.apache.org/job/incubator-netbeans-linux/lastCompletedBuild/testReport/").get(); + Elements unittestfailurereport = jenkinsresults.select("a.model-link"); + for (Element link : unittestfailurereport) { + if (link.text().contains(pattern)) { + String[] split = link.text().split(". module "); + String[] split1 = split[1].split(" has "); + String modulename = split1[0]; + links.put(modulename, link); + } + } + scanWikiAndGenerate(); + } + + private void scanWikiAndGenerate() throws IOException { + + Document confluence = Jsoup.connect("https://cwiki.apache.org/confluence/display/NETBEANS/List+of+Modules+to+Review").get(); + + int missingModules = links.size(); + Elements areas = confluence.select("h3"); + Sink sink = getSink(); + sink.sectionTitle2(); + sink.rawText("Need to find: " + missingModules + " entries"); + sink.sectionTitle2_(); + for (Element area : areas) { + String text = area.text(); + if (text.contains("Area:")) { + + sink.sectionTitle3(); + sink.text(text.replaceAll("Area:", "")); + sink.sectionTitle3_(); + sink.table(); + Elements allrows = area.nextElementSibling().select("tr"); + for (Element arow : allrows) { + String trim = arow.children().get(0).text().trim(); + if (links.containsKey(trim)) { + missingModules--; + sink.tableRow(); + sink.tableCell("50px"); + sink.link("https://builds.apache.org/job/incubator-netbeans-linux/lastCompletedBuild/testReport/" + links.get(trim).attr("href")); + sink.rawText("Report"); + sink.link_(); + sink.tableCell_(); + sink.tableCell("300px"); + sink.rawText(arow.children().get(0).text().trim()); + sink.tableCell_(); + sink.tableCell("300px"); + sink.rawText(arow.children().get(1).text().trim()); + sink.tableCell_(); + sink.tableCell(); + sink.rawText(arow.children().get(2).text().trim()); + sink.tableCell_(); + /*sink.tableCell(); + sink.rawText(arow.children().get(3).text().trim()); + sink.tableCell_(); + */ + links.remove(trim); + sink.tableRow_(); + } + + } + sink.table_(); + } + } + sink.sectionTitle2(); + sink.rawText("Remains : " + missingModules + " entries"); + sink.sectionTitle2_(); + + } +} diff --git a/licencereviewsite/src/site/site.xml b/licencereviewsite/src/site/site.xml new file mode 100644 index 0000000..393e09e --- /dev/null +++ b/licencereviewsite/src/site/site.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" name="LicenceStatus"> + <skin> + <groupId>org.apache.maven.skins</groupId> + <artifactId>maven-fluido-skin</artifactId> + <version>1.6</version> + </skin> + <bannerLeft> + <name>Licence Status</name> + </bannerLeft> + <body> + <menu> + <item name="RAT" href="reviewlicence.html"/> + </menu> + </body> +</project> \ No newline at end of file ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
