Search in sources :

Example 1 with Project

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"));
    }
}
Also used : Project(org.apache.tools.ant.Project) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) Test(org.junit.Test)

Example 2 with Project

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;
}
Also used : CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) Matcher(java.util.regex.Matcher) Constructor(java.lang.reflect.Constructor) ExpandProperties(org.apache.tools.ant.filters.ExpandProperties) Project(org.apache.tools.ant.Project) File(java.io.File) FilterReader(java.io.FilterReader)

Example 3 with Project

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();
}
Also used : Project(org.apache.tools.ant.Project) Target(org.apache.tools.ant.Target) Expand(org.apache.tools.ant.taskdefs.Expand)

Example 4 with Project

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();
}
Also used : Project(org.apache.tools.ant.Project) Target(org.apache.tools.ant.Target) Tar(org.apache.tools.ant.taskdefs.Tar)

Example 5 with Project

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();
}
Also used : Project(org.apache.tools.ant.Project) Target(org.apache.tools.ant.Target) GZip(org.apache.tools.ant.taskdefs.GZip)

Aggregations

Project (org.apache.tools.ant.Project)259 File (java.io.File)100 Test (org.junit.Test)71 BuildException (org.apache.tools.ant.BuildException)58 Before (org.junit.Before)34 IOException (java.io.IOException)33 Path (org.apache.tools.ant.types.Path)24 FileSet (org.apache.tools.ant.types.FileSet)22 Commandline (org.apache.tools.ant.types.Commandline)19 Test (org.junit.jupiter.api.Test)14 DefaultLogger (org.apache.tools.ant.DefaultLogger)12 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)12 Delete (org.apache.tools.ant.taskdefs.Delete)12 ZipFile (java.util.zip.ZipFile)10 Properties (java.util.Properties)9 ProjectHelper (org.apache.tools.ant.ProjectHelper)9 PrintStream (java.io.PrintStream)8 IgniteDeploymentGarAntTask (org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask)8 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)7 GridCommonTest (org.apache.ignite.testframework.junits.common.GridCommonTest)7