Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[FIXED JENKINS-17047] Make dependency to ant plug-in optional.
  • Loading branch information
uhafner committed Aug 11, 2013
1 parent eb66f04 commit f0f8dd454360d3c0bc320d2eb64abf48ee85471a
Showing 3 changed files with 48 additions and 9 deletions.
@@ -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>
@@ -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
}
}

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

/**
@@ -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} */

0 comments on commit f0f8dd4

Please sign in to comment.