Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-6127] Parsing of maven projects now starts in pom folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Aug 19, 2011
1 parent dd79186 commit 42d5a2d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 44 deletions.
5 changes: 3 additions & 2 deletions src/main/java/hudson/plugins/tasks/TasksPublisher.java
Expand Up @@ -201,9 +201,10 @@ public Action getProjectAction(final AbstractProject<?, ?> project) {
protected BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger logger) throws InterruptedException, IOException {
TasksParserResult project;
logger.log("Scanning workspace files for tasks...");
WorkspaceScanner scanner = new WorkspaceScanner(StringUtils.defaultIfEmpty(getPattern(),
DEFAULT_PATTERN), getExcludePattern(), getDefaultEncoding(), high, normal, low, ignoreCase, shouldDetectModules());
WorkspaceScanner scanner = new WorkspaceScanner(StringUtils.defaultIfEmpty(getPattern(), DEFAULT_PATTERN),
getExcludePattern(), getDefaultEncoding(), high, normal, low, ignoreCase, shouldDetectModules());
project = build.getWorkspace().act(scanner);
logger.log(String.format("Found %d open tasks.", project.getNumberOfAnnotations()));

TasksResult result = new TasksResult(build, getDefaultEncoding(), project, high, normal, low);
build.getActions().add(new TasksResultAction(build, this, result));
Expand Down
40 changes: 5 additions & 35 deletions src/main/java/hudson/plugins/tasks/TasksReporter.java
Expand Up @@ -13,12 +13,10 @@
import hudson.plugins.tasks.parser.WorkspaceScanner;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
import org.kohsuke.stapler.DataBoundConstructor;

Expand Down Expand Up @@ -198,40 +196,12 @@ protected boolean acceptGoal(final String goal) {
@SuppressWarnings("PMD.AvoidFinalLocalVariable")
@Override
public TasksParserResult perform(final MavenBuildProxy build, final MavenProject pom, final MojoInfo mojo, final PluginLogger logger) throws InterruptedException, IOException {
List<String> foldersToScan = new ArrayList<String>(pom.getCompileSourceRoots());
foldersToScan.addAll(pom.getTestCompileSourceRoots());

List<Resource> resources = pom.getResources();
for (Resource resource : resources) {
foldersToScan.add(resource.getDirectory());
}
resources = pom.getTestResources();
for (Resource resource : resources) {
foldersToScan.add(resource.getDirectory());
}

FilePath basedir = new FilePath(pom.getBasedir());
final TasksParserResult project = new TasksParserResult();
for (String sourcePath : foldersToScan) {
if (StringUtils.isEmpty(sourcePath)) {
continue;
}
FilePath filePath = new FilePath(basedir, sourcePath);
if (filePath.exists()) {
logger.log(String.format("Scanning folder '%s' for tasks ... ", sourcePath));
WorkspaceScanner workspaceScanner = new WorkspaceScanner(StringUtils.defaultIfEmpty(pattern, DEFAULT_PATTERN),
excludePattern, getDefaultEncoding(), high, normal, low, ignoreCase, pom.getName());
workspaceScanner.setPrefix(sourcePath);
TasksParserResult subProject = filePath.act(workspaceScanner);
project.addAnnotations(subProject.getAnnotations());
project.addModule(pom.getName());
project.addScannedFiles(subProject.getNumberOfScannedFiles());
logger.log(String.format("Found %d.", subProject.getNumberOfAnnotations()));
}
else {
logger.log(String.format("Skipping non-existent folder '%s'...", sourcePath));
}
}
logger.log(String.format("Scanning folder '%s' for tasks ... ", basedir));
WorkspaceScanner workspaceScanner = new WorkspaceScanner(StringUtils.defaultIfEmpty(pattern, DEFAULT_PATTERN),
excludePattern, getDefaultEncoding(), high, normal, low, ignoreCase, pom.getName());
TasksParserResult project = basedir.act(workspaceScanner);
logger.log(String.format("Found %d open tasks.", project.getNumberOfAnnotations()));

return project;
}
Expand Down
@@ -1,7 +1,5 @@
description.files=<a href="{0}">Fileset 'includes'</a> \
setting that specifies the workspace files to scan for tasks, such as '**/*.java'. \
All in the POM defined source directories are scanned with the specified fileset. \
If no value is set, then the default '**/*.java' is used.
description.exclude.files=<a href="{0}">Fileset 'excludes'</a> \
setting that specifies the workspace files to exclude scanning for tasks, such as library source files. \
All in the POM defined source directories are scanned with the specified fileset.
setting that specifies the workspace files to exclude scanning for tasks, such as library source files.
@@ -1,13 +1,11 @@
Files\ to\ scan=Zu untersuchende Dateien
0Files\ to\ scan=Zu untersuchende Dateien
Files\ to\ exclude=Zu ignorierende Dateien

description.files=Angabe einer <a href="{0}">ANT Fileset 'includes'</a> \
Anweisung, die den Pfad der zu untersuchenden Dateien bestimmt, z.B. '**/*.java'. \
Als Ausgangsverzeichnis für diese Anweisung werden alle im POM definierten Source Pfade verwendet. \
Falls kein Wert eingetragen wird, dann wird die Vorgabe '**/*.java' benutzt.
description.exclude.files=Angabe einer <a href="{0}">ANT Fileset 'excludes'</a> \
Anweisung, die die Dateien angibt, die beim Scannen nicht berücksichtigt werden sollen, z.B. Dateien von Fremdbibliotheken. \
Als Ausgangsverzeichnis für diese Anweisung werden alle im POM definierten Source Pfade verwendet.
Anweisung, die die Dateien angibt, die beim Scannen nicht berücksichtigt werden sollen, z.B. Dateien von Fremdbibliotheken.



0 comments on commit 42d5a2d

Please sign in to comment.