use of org.apache.tools.ant.Project in project checkstyle by checkstyle.
the class CheckstyleAntTaskTest method testNonExistingConfig.
@Test
public final void testNonExistingConfig() throws IOException {
final CheckstyleAntTask antTask = new CheckstyleAntTask();
antTask.setConfig(new File(getPath(NOT_EXISTING_FILE)));
antTask.setProject(new Project());
antTask.setFile(new File(getPath(FLAWLESS_INPUT)));
try {
antTask.execute();
fail("Exception is expected");
} catch (BuildException ex) {
assertTrue(ex.getMessage().startsWith("Unable to create Root Module: configLocation"));
}
}
use of org.apache.tools.ant.Project in project intellij-community by JetBrains.
the class ChainingFilterTransformer method doTransform.
private Reader doTransform(ResourceRootFilter filter, Reader original) {
if ("RenamingCopyFilter".equals(filter.filterType)) {
final Matcher matcher = (Matcher) filter.getProperties().get("matcher");
final String replacement = (String) filter.getProperties().get("replacement");
if (matcher == null || replacement == null)
return original;
matcher.reset(myOutputFileRef.get().getName());
if (matcher.find()) {
final String newFileName = matcher.replaceFirst(replacement);
myOutputFileRef.set(new File(myOutputFileRef.get().getParentFile(), newFileName));
}
return original;
}
try {
Class<?> clazz = Class.forName(filter.filterType);
if (!FilterReader.class.isAssignableFrom(clazz)) {
myContext.processMessage(new CompilerMessage(GradleResourcesBuilder.BUILDER_NAME, BuildMessage.Kind.WARNING, String.format("Error - Invalid filter specification for %s. It should extend java.io.FilterReader.", filter.filterType), null));
}
Constructor constructor = clazz.getConstructor(Reader.class);
FilterReader result = (FilterReader) constructor.newInstance(original);
final Map<Object, Object> properties = filter.getProperties();
if (!properties.isEmpty()) {
if (ExpandProperties.class.getName().equals(filter.filterType)) {
final Map<Object, Object> antProps = new HashMap<>(properties);
final Project project = new Project();
for (Map.Entry<Object, Object> entry : antProps.entrySet()) {
project.setProperty(entry.getKey().toString(), entry.getValue().toString());
}
properties.clear();
properties.put("project", project);
}
ConfigureUtil.configureByMap(properties, result);
}
return result;
} catch (Throwable th) {
myContext.processMessage(new CompilerMessage(GradleResourcesBuilder.BUILDER_NAME, BuildMessage.Kind.WARNING, String.format("Error - Failed to apply filter(%s): %s", filter.filterType, th.getMessage()), null));
}
return original;
}
use of org.apache.tools.ant.Project in project adempiere by adempiere.
the class CreateZipFile method unpackFile.
public static void unpackFile(File zipFilepath, File destinationDir) {
Expand Unzipper = new Expand();
Unzipper.setDest(destinationDir);
Unzipper.setSrc(zipFilepath);
Unzipper.setTaskType("unzip");
Unzipper.setTaskName("unzip");
Unzipper.setProject(new Project());
Unzipper.setOwningTarget(new Target());
Unzipper.execute();
}
use of org.apache.tools.ant.Project in project adempiere by adempiere.
the class CreateZipFile method tarFolder.
public static void tarFolder(File srcFolder, File destTarFile, String includesdir) {
Tar tarer = new Tar();
tarer.setDestFile(destTarFile);
tarer.setBasedir(srcFolder);
tarer.setIncludes(includesdir);
tarer.setCaseSensitive(false);
tarer.setTaskName("tar");
tarer.setTaskType("tar");
tarer.setProject(new Project());
tarer.setOwningTarget(new Target());
tarer.execute();
}
use of org.apache.tools.ant.Project in project adempiere by adempiere.
the class CreateZipFile method gzipFile.
public static void gzipFile(File srcFile, File destFile) {
GZip GZiper = new GZip();
GZiper.setDestfile(destFile);
GZiper.setSrc(srcFile);
GZiper.setTaskName("gzip");
GZiper.setTaskType("gzip");
GZiper.setProject(new Project());
GZiper.setOwningTarget(new Target());
GZiper.execute();
}
Aggregations