[pkg-java] r14133 - in trunk/maven-repo-helper: . debian src/main/bin src/main/java/org/debian/maven/repo
Damien Raude-Morvan
drazzib at alioth.debian.org
Tue Aug 9 21:02:52 UTC 2011
Author: drazzib
Date: 2011-08-09 21:02:52 +0000 (Tue, 09 Aug 2011)
New Revision: 14133
Added:
trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportHTMLWriter.java
trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportTextWriter.java
trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportWriter.java
Modified:
trunk/maven-repo-helper/
trunk/maven-repo-helper/debian/changelog
trunk/maven-repo-helper/src/main/bin/mh_checkrepo
trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Repository.java
Log:
* TODO: Add support for packages built with dh 7 and javahelper: use
the following line in your rules file:
* src/main/java/org/debian/maven/repo/RepositoryReportWriter.java: Add
a hack to change output of Maven repository checker.
Property changes on: trunk/maven-repo-helper
___________________________________________________________________
Modified: svn:ignore
- .classpath
.project
bin
+ .classpath
.project
bin
target
.settings
Modified: trunk/maven-repo-helper/debian/changelog
===================================================================
--- trunk/maven-repo-helper/debian/changelog 2011-08-09 21:02:29 UTC (rev 14132)
+++ trunk/maven-repo-helper/debian/changelog 2011-08-09 21:02:52 UTC (rev 14133)
@@ -1,9 +1,9 @@
-maven-repo-helper (1.5.2) UNRELEASED; urgency=low
+maven-repo-helper (1.5.2) unstable; urgency=low
[ Ludovic Claude ]
* Match jar with bundle as they are equivalent
- * TODO: Add support for packages built with dh 7 and javahelper: use the following
- line in your rules file:
+ * TODO: Add support for packages built with dh 7 and javahelper: use
+ the following line in your rules file:
dh $@ --with javahelper --with jh_mavenrepohelper
This will build the package with javahelper, and the resulting
jar will be installed in the Maven repository (you need of course the
@@ -12,8 +12,10 @@
[ Damien Raude-Morvan ]
* Keep relativePath attribute on parent pom.
* d/control: Fix typo in package description (Closes: #617438).
+ * src/main/java/org/debian/maven/repo/RepositoryReportWriter.java: Add
+ a hack to change output of Maven repository checker.
- -- Damien Raude-Morvan <drazzib at debian.org> Sat, 23 Jul 2011 16:42:59 +0200
+ -- Damien Raude-Morvan <drazzib at debian.org> Tue, 09 Aug 2011 22:57:51 +0200
maven-repo-helper (1.5.1) unstable; urgency=low
Modified: trunk/maven-repo-helper/src/main/bin/mh_checkrepo
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_checkrepo 2011-08-09 21:02:29 UTC (rev 14132)
+++ trunk/maven-repo-helper/src/main/bin/mh_checkrepo 2011-08-09 21:02:52 UTC (rev 14133)
@@ -31,17 +31,9 @@
echo -e "\t-h --help: show this text"
echo -e "\t-V --version: show the version"
echo -e "\t-v --verbose: show more information while running"
+ echo -e "\t-o<format>, --output=<format>: 'text' or 'html' to change output format"
+ echo -e "\t-r<repository>, --repository=<repository>: directory of Maven repository"
exit 1
}
-ARGS="v verbose n" parseargs "$@"
-
-VERBOSE=$(getarg v verbose)
-
-if [ "$ARGC" -gt "0" ]; then
- REPO="${ARGV[0]}"
-else
- REPO="/usr/share/maven-repo"
-fi
-
-java -cp $CLASSPATH $JAVA_OPTIONS org.debian.maven.repo.Repository $REPO
+java -cp $CLASSPATH $JAVA_OPTIONS org.debian.maven.repo.Repository "$@"
Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Repository.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Repository.java 2011-08-09 21:02:29 UTC (rev 14132)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Repository.java 2011-08-09 21:02:52 UTC (rev 14133)
@@ -24,10 +24,20 @@
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+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.stream.XMLStreamException;
/**
@@ -184,37 +194,44 @@
scanned = true;
}
- public void report() {
+ public void report(RepositoryReportWriter writer) {
+ writer.printStart();
+
if (pomsWithMissingParent.size() > 0) {
- System.out.println("POMs with missing parents:");
+ writer.printSectionStart("POMs with missing parents");
for (Iterator i = pomsWithMissingParent.keySet().iterator(); i.hasNext();) {
File pom = (File) i.next();
- System.out.println("\t" + pom.getAbsolutePath());
+ writer.printItem(pom.getAbsolutePath());
+ writer.endItem();
}
+ writer.printSectionEnd();
}
if (pomsWithMissingVersions.size() > 0) {
- System.out.println("POMs with missing versions:");
+ writer.printSectionStart("POMs with missing versions");
for (Iterator i = pomsWithMissingVersions.entrySet().iterator(); i.hasNext();) {
Entry entry = (Entry) i.next();
File pom = (File) entry.getKey();
POMInfo pomInfo = (POMInfo) entry.getValue();
- System.out.println("\t" + pom.getAbsolutePath());
+ writer.printItem(pom.getAbsolutePath());
for (Iterator j = pomInfo.getDependencies().iterator(); j.hasNext();) {
Dependency dependency = (Dependency) j.next();
if (dependency.getVersion() == null || dependency.getVersion().contains("$")) {
- System.out.println("\t\t" + dependency);
+ writer.printItem(dependency.toString());
+ writer.endItem();
}
}
for (Iterator j = pomInfo.getPlugins().iterator(); j.hasNext();) {
Dependency dependency = (Dependency) j.next();
if (dependency.getVersion() == null || dependency.getVersion().contains("$")) {
- System.out.println("\t\t" + dependency);
+ writer.printItem(dependency.toString());
+ writer.endItem();
}
}
+ writer.endItem();
}
+ writer.printSectionEnd();
}
- System.out.println();
Set issues = new TreeSet();
Map pomsWithIssues = new HashMap();
@@ -254,11 +271,13 @@
}
}
+ writer.printSectionStart("Errors");
for (Iterator i = issues.iterator(); i.hasNext();) {
String issue = (String) i.next();
- System.out.println(issue);
+ writer.printItem(issue);
+ writer.endItem();
}
- System.out.println();
+ writer.printSectionEnd();
// Find the poms with most issues
Map pomsWithNumberOfIssues = new TreeMap(Collections.reverseOrder());
@@ -275,20 +294,23 @@
orderedPoms.add(pom);
}
if (!pomsWithNumberOfIssues.isEmpty()) {
- System.out.println("Top 10 POM files with issues:");
+ writer.printSectionStart("Top 10 POM files with issues");
int count = 0;
for (Iterator i = pomsWithNumberOfIssues.values().iterator(); i.hasNext() && count < 10;) {
List orderedPoms = (List) i.next();
for (Iterator j = orderedPoms.iterator(); j.hasNext() && count < 10; count++) {
File pom = (File) j.next();
List missingDeps = (List) pomsWithIssues.get(pom);
- System.out.println("Missing dependencies in " + pom);
+ writer.printItem("Missing dependencies in " + pom);
for (Iterator k = missingDeps.iterator(); k.hasNext();) {
Dependency dependency = (Dependency) k.next();
- System.out.println("\t" + dependency);
+ writer.printItem(dependency.toString());
+ writer.endItem();
}
+ writer.endItem();
}
}
+ writer.printSectionEnd();
}
// Find the dependencies that need packaging most
@@ -317,15 +339,19 @@
}
});
if (! missingDependenciesCountList.isEmpty()) {
- System.out.println("Top 10 missing dependencies:");
+ writer.printSectionStart("Top 10 missing dependencies");
int count = 0;
for (Iterator i = missingDependenciesCountList.iterator(); i.hasNext() && count < 10; count++) {
Map.Entry entry = (Entry) i.next();
Dependency missingDependency = (Dependency) entry.getKey();
Integer numberOfTimes = (Integer) entry.getValue();
- System.out.println("Missing dependency " + missingDependency + " is needed in " + numberOfTimes + " places");
+ writer.printItem("Missing dependency " + missingDependency + " is needed in " + numberOfTimes + " places");
+ writer.endItem();
}
+ writer.printSectionEnd();
}
+
+ writer.printEnd();
}
private void resolveAll(Map file2pom) {
@@ -410,15 +436,54 @@
}
public static void main(String[] args) {
- String repoLocation = "/usr/share/maven-repo";
- if (args.length > 0) {
- repoLocation = args[0];
+ File repoLocation = new File("/usr/share/maven-repo");
+
+ if (args != null && "-h".equals(args[0]) || "--help".equals(args[0])) {
+ System.out.println("Purpose: Check content of a Maven repository.");
+ System.out.println("Usage: [option]");
+ System.out.println("");
+ System.out.println("Options:");
+ System.out.println(" -v, --verbose: be extra verbose");
+ System.out.println(" -o<format>, --output=<format>: 'text' or 'html' to change output format");
+ System.out.println(" -r<repository>, --repository=<repository>: directory of Maven repository");
+ return;
}
- System.out.println("Scanning repository...");
- Repository repository = new Repository(new File(repoLocation));
+
+ String format = "text";
+
+ // Parse parameters
+ int i = inc(-1, args);
+ while (i < args.length && (args[i].trim().startsWith("-") || args[i].trim().isEmpty())) {
+ String arg = args[i].trim();
+ if (arg.startsWith("-o")) {
+ format = arg.substring(2);
+ } else if (arg.startsWith("--output=")) {
+ format = arg.substring("--output=".length());
+ } else if (arg.startsWith("-r")) {
+ repoLocation = new File(arg.substring(2));
+ } else if (arg.startsWith("--repository=")) {
+ repoLocation = new File(arg.substring("--repository=".length()));
+ }
+ i = inc(i, args);
+ }
+
+ Repository repository = new Repository(repoLocation);
+ RepositoryReportWriter reportWriter;
+ if ("text".equals(format)) {
+ reportWriter = new RepositoryReportTextWriter();
+ } else {
+ reportWriter = new RepositoryReportHTMLWriter();
+ }
+
repository.scan();
- repository.report();
- System.out.println("Done.");
+ repository.report(reportWriter);
}
+ private static int inc(int i, String[] args) {
+ do {
+ i++;
+ } while (i < args.length && args[i].isEmpty());
+ return i;
+ }
+
}
Added: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportHTMLWriter.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportHTMLWriter.java (rev 0)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportHTMLWriter.java 2011-08-09 21:02:52 UTC (rev 14133)
@@ -0,0 +1,93 @@
+package org.debian.maven.repo;
+
+/*
+ * Copyright 2011 Damien Raude-Morvan.
+ *
+ * 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.
+ */
+
+/**
+ *
+ * @author Damien Raude-Morvan <drazzib at debian.org>
+ */
+public class RepositoryReportHTMLWriter implements RepositoryReportWriter {
+
+ /** Current level of item */
+ private int itemLevel = 1;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printSectionStart(String string) {
+ String display = string + ":";
+
+ System.out.println("<h2>");
+ System.out.println(display);
+ System.out.println("</h2>");
+ System.out.println("<ul>");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printSectionEnd() {
+ System.out.println("</ul>");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printItem(String string) {
+ if (itemLevel > 1) {
+ System.out.print("<ul>");
+ }
+ System.out.print("<li>");
+ System.out.print(string);
+ itemLevel++;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void endItem() {
+ itemLevel--;
+ System.out.println("</li>");
+ if (itemLevel > 1) {
+ System.out.print("</ul>");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printStart() {
+ System.out.println("<html>");
+ System.out.println("<header>");
+ System.out.println("<title>Debian Maven repository QA</title>");
+ System.out
+ .println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>");
+ System.out.println("</header>");
+ System.out.println("<body>");
+ System.out.println("<h1>Debian Maven repository QA</h1>");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printEnd() {
+ System.out.println("</body>");
+ System.out.println("</html>");
+
+ }
+
+}
Added: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportTextWriter.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportTextWriter.java (rev 0)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportTextWriter.java 2011-08-09 21:02:52 UTC (rev 14133)
@@ -0,0 +1,79 @@
+package org.debian.maven.repo;
+
+/*
+ * Copyright 2011 Damien Raude-Morvan.
+ *
+ * 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.
+ */
+
+/**
+ *
+ * @author Damien Raude-Morvan <drazzib at debian.org>
+ */
+public class RepositoryReportTextWriter implements RepositoryReportWriter {
+
+ /** Current level of item */
+ private int itemLevel = 1;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printSectionStart(String string) {
+ String display = string + ":";
+
+ System.out.println(display.replaceAll(".", "="));
+ System.out.println(display);
+ System.out.println(display.replaceAll(".", "="));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printSectionEnd() {
+ System.out.println();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printItem(String string) {
+ System.out.print("\t");
+ if (itemLevel > 1) {
+ System.out.print("\t");
+ }
+ System.out.println(string);
+ itemLevel++;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void endItem() {
+ itemLevel--;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printStart() {
+ System.out.println("Scanning repository...");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printEnd() {
+ System.out.println("Done.");
+ }
+
+}
Added: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportWriter.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportWriter.java (rev 0)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/RepositoryReportWriter.java 2011-08-09 21:02:52 UTC (rev 14133)
@@ -0,0 +1,59 @@
+package org.debian.maven.repo;
+/*
+ * Copyright 2011 Damien Raude-Morvan.
+ *
+ * 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.
+ */
+
+/**
+ * Interface of any check's output.
+ *
+ * @author Damien Raude-Morvan <drazzib at debian.org>
+ */
+public interface RepositoryReportWriter {
+
+ /**
+ * Print start part of any Item
+ *
+ * @param string content of message to print
+ */
+ void printItem(String string);
+
+ /**
+ * Print end part of any Item
+ */
+ void endItem();
+
+ /**
+ * Print start of a report section
+ *
+ * @param string content of message to print
+ */
+ void printSectionStart(String string);
+
+ /**
+ * Print end of a report section
+ */
+ void printSectionEnd();
+
+ /**
+ * Print end footer of the report
+ */
+ void printEnd();
+
+ /**
+ * Print start header of the report
+ */
+ void printStart();
+
+}
More information about the pkg-java-commits
mailing list