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

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-17047] Make dependency to ant plug-in optional.
  • Loading branch information
uhafner committed Aug 11, 2013
1 parent eb66f04 commit f0f8dd4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -21,6 +21,7 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ant</artifactId>
<version>1.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>de.java2html</groupId>
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/hudson/plugins/analysis/core/AntBuilderCheck.java
@@ -0,0 +1,42 @@
package hudson.plugins.analysis.core;

import hudson.model.AbstractBuild;
import hudson.model.Project;

import hudson.tasks.Builder;
import hudson.tasks.Ant;

/**
* Verifies if the build is an {@link Ant} task.
*
* @author Ulli Hafner
*/
public final class AntBuilderCheck {
/**
* Returns whether the current build uses ant.
*
* @param build
* the current build
* @return <code>true</code> if the current build uses ant,
* <code>false</code> otherwise
*/
public static boolean isAntBuild(final AbstractBuild<?, ?> build) {
if (build.getProject() instanceof Project) {
Project<?, ?> project = (Project<?, ?>)build.getProject();
for (Builder builder : project.getBuilders()) {
if (builder instanceof Ant) {
return true;
}
}
}
return false;
}

/**
* Creates a new instance of {@link AntBuilderCheck}.
*/
private AntBuilderCheck() {
// prevent instantiation
}
}

Expand Up @@ -35,7 +35,6 @@
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Builder;
import hudson.tasks.Recorder;
import hudson.tasks.Ant;
import hudson.tasks.Maven;

/**
Expand Down Expand Up @@ -607,15 +606,12 @@ protected boolean isMavenBuild(final AbstractBuild<?, ?> build) {
* <code>false</code> otherwise
*/
protected boolean isAntBuild(final AbstractBuild<?, ?> build) {
if (build.getProject() instanceof Project) {
Project<?, ?> project = (Project<?, ?>)build.getProject();
for (Builder builder : project.getBuilders()) {
if (builder instanceof Ant) {
return true;
}
}
try {
return AntBuilderCheck.isAntBuild(build);
}
catch (Throwable exception) { // NOPMD NOCHECKSTYLE
return false; // fallback if ant is not installed
}
return false;
}

/** {@inheritDoc} */
Expand Down

0 comments on commit f0f8dd4

Please sign in to comment.