blob: dcbfeae40b11bb641d4e97b86a5546f4b898b4d7 [file] [log] [blame]
package org.eclipse.juno.tests.jars;
import java.io.File;
import org.apache.tools.ant.BuildException;
public abstract class TestJars {
private String bundleDirectory;
private String featureDirectory;
private String directoryToCheck;
private String tempWorkingDir;
private String outputDirectory;
public String getDirectoryToCheck() {
return directoryToCheck;
}
public void setDirectoryToCheck(String bundleDirToCheck) {
this.directoryToCheck = bundleDirToCheck;
}
public String getOutputDirectory() {
if (outputDirectory == null) {
outputDirectory = System.getProperty("user.dir");
}
return outputDirectory;
}
public String getTempWorkingDir() {
return tempWorkingDir;
}
public void setTempWorkingDir(String tempWorkingDir) {
this.tempWorkingDir = tempWorkingDir;
}
public void setOutputDirectory(String outputDirectory) {
this.outputDirectory = outputDirectory;
}
protected String getBundleDirectory() {
if (bundleDirectory == null) {
// we try both aggregate/plugins and if doesn't exist, assume plugins
String AGGR_PLUGINS_DIR = "aggregate/plugins";
String PLUGINS_DIR = "plugins";
String property = getDirectoryToCheck();
if (property == null) {
throw new BuildException("Need to set input directory to check against.");
}
property = ensureEndingSlash(property);
// try aggregate first
bundleDirectory = property + AGGR_PLUGINS_DIR;
File inputdir = new File(bundleDirectory);
if (!(inputdir.exists() && inputdir.isDirectory())) {
// then try more common non-aggregate plugins directory
bundleDirectory = property + PLUGINS_DIR;
inputdir = new File(bundleDirectory);
if (!(inputdir.exists() && inputdir.isDirectory())) {
throw new BuildException("bundle direcotry (" + bundleDirectory + ") must be an existing directory.");
}
}
}
return bundleDirectory;
}
private String ensureEndingSlash(String property) {
String result = property;
if (!result.endsWith("/")) {
result = result + "/";
}
return result;
}
protected String getFeatureDirectory() {
if (featureDirectory == null) {
// we try both aggregate/plugins and if doesn't exist, assume plugins
String AGGR_FEATURES_DIR = "aggregate/features";
String FEATURES_DIR = "features";
String property = getDirectoryToCheck();
if (property == null) {
throw new BuildException("Need to set input directory to check against.");
}
property = ensureEndingSlash(property);
// try aggregate first
featureDirectory = property + AGGR_FEATURES_DIR;
File inputdir = new File(featureDirectory);
if (!(inputdir.exists() && inputdir.isDirectory())) {
// then try more common non-aggregate plugins directory
featureDirectory = property + FEATURES_DIR;
inputdir = new File(featureDirectory);
if (!(inputdir.exists() && inputdir.isDirectory())) {
throw new BuildException("feature direcotry (" + featureDirectory + ") must be an existing directory.");
}
}
}
return featureDirectory;
}
}