Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
Various changes to make it work reliably
Browse files Browse the repository at this point in the history
  • Loading branch information
gousiosg committed Jan 17, 2012
1 parent 3d4aa75 commit b6bfe85
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkdir -p runner/bundles/configuration
cat runner/equinox/config.ini| sed -e's/bundles\///' > runner/bundles/configuration/config.ini

cd runner/bundles
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y -Xmx1000M $* -jar $OSGI -console && rm -R configuration/config.ini && cd -
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y -Xmx1000M $@ -jar $OSGI -console && rm -R configuration/config.ini && cd -

Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,19 @@
@SchedulerHints(invocationOrder = InvocationOrder.NEWFIRST)
public class FindbugsMetrics extends AbstractMetric {

final String MAVEN_PATH = "mvn";
final String FINDBUGS_PATH = "findbugs";
static String MAVEN_PATH = "";
static String FINDBUGS_PATH = "";

static {
if (System.getProperty("findbugs.path") != null)
FINDBUGS_PATH = System.getProperty("findbugs.path");
else
FINDBUGS_PATH = "findbugs";
if (System.getProperty("mvn.path") != null)
MAVEN_PATH = System.getProperty("mvn.path");
else
MAVEN_PATH = "mvn";
}

public FindbugsMetrics(BundleContext bc) {
super(bc);
Expand Down Expand Up @@ -123,13 +134,14 @@ public void run(ProjectVersion pv) {
log.warn("Build with maven failed. See file:" + out);
}

List<File> jars = FileUtils.findGrep(checkout, Pattern.compile("target/.*\\.jar$"));
List<File> jars = getJars(checkout);

for(File jar: jars) {

String pkgs = getPkgs(pv.getFiles(Pattern.compile("src/main/java/"),
ProjectVersion.MASK_FILES));
pkgs = pkgs.substring(0, pkgs.length() - 1);
String findbugsOut = pv.getRevisionId()+"-" + jar.getName() + "-" +pv.getProject().getName() + ".xml";

List<String> findbugsArgs = new ArrayList<String>();
findbugsArgs.add(FINDBUGS_PATH);
Expand All @@ -138,27 +150,20 @@ public void run(ProjectVersion pv) {
findbugsArgs.add(pkgs);
findbugsArgs.add("-xml");
findbugsArgs.add("-output");
// dimitro: I have added a specific path for the output file. You can do that too.
findbugsArgs.add(
"/Users/dimitro/Documents/PhD/FindBugs+Alitheia/Alitheia-Core/runner/"+
pv.getRevisionId()+"-"+pv.getProject().getName() + ".xml");
findbugsArgs.add(findbugsOut);
findbugsArgs.add(jar.getAbsolutePath());
//dimitro
System.out.println("dimitro: the arguments fed to FindBugs are: "+findbugsArgs);
//dimitro

ProcessBuilder findbugs = new ProcessBuilder(findbugsArgs);
findbugs.directory(pom.getParentFile());
findbugs.redirectErrorStream(true);
retVal = runReadOutput(findbugs.start(), out);

if (retVal != 0) {
log.warn("Build with findbugs failed. See file:" + out);
log.warn("Findbugs failed. See file:" + out);
}

File f = new File(pv.getRevisionId()+"-"+pv.getProject().getName() + ".xml");
File f = new File(findbugsOut);
parseFindbugsResults(f);


}
} catch (CheckoutException e) {
e.printStackTrace();
Expand Down Expand Up @@ -192,6 +197,22 @@ public String getPkgs(List<ProjectFile> files) {

return sb.toString();
}

public List<File> getJars(File checkout) {
List<File> jars = FileUtils.findGrep(checkout, Pattern.compile("target/.*\\.jar$"));
List<File> result = new ArrayList<File>();
//Exclude common maven output jar patterns
for(File f: jars) {
if (f.getName().endsWith("-sources.jar"))
continue;
if (f.getName().endsWith("with-dependencies.jar"))
continue;
if (f.getName().endsWith("-javadoc.jar"))
continue;
result.add(f);
}
return result;
}

public int runReadOutput(Process pr, String name) throws IOException {
OutReader outReader = new OutReader(pr.getInputStream(), name);
Expand Down

0 comments on commit b6bfe85

Please sign in to comment.