Search in sources :

Example 71 with Project

use of org.apache.tools.ant.Project in project aries by apache.

the class EsaTaskTest method generateArchiveWithFileManifest.

@Test
public void generateArchiveWithFileManifest() {
    File srcDir = new File("../src/test/resources");
    File destfile = new File("target/esa-test2.esa");
    if (destfile.exists()) {
        destfile.delete();
    }
    assertFalse(destfile.exists());
    EsaTask esaTask = new EsaTask();
    Project testProject = new Project();
    esaTask.setProject(testProject);
    FileSet fileSet = new FileSet();
    fileSet.setDir(srcDir);
    fileSet.setIncludes("*.jar");
    esaTask.addFileset(fileSet);
    esaTask.setDestFile(destfile);
    esaTask.setSymbolicName("esatask-test");
    esaTask.setVersion("1.0.0");
    esaTask.setManifest(new File(srcDir, "SUBSYSTEM.MF"));
    esaTask.execute();
    assertTrue(destfile.exists());
    try {
        ZipFile esaArchive = new ZipFile(destfile);
        assertNotNull(esaArchive);
        ZipEntry subsystemManifest = esaArchive.getEntry("OSGI-INF/SUBSYSTEM.MF");
        assertNotNull(subsystemManifest);
    } catch (IOException e) {
        fail(e.getMessage());
    }
}
Also used : Project(org.apache.tools.ant.Project) FileSet(org.apache.tools.ant.types.FileSet) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 72 with Project

use of org.apache.tools.ant.Project in project ceylon-compiler by ceylon.

the class SelectToolTask method execute.

@Override
public void execute() {
    Project p = getProject();
    Properties props = readProperties(propertyFile);
    toolName = props.getProperty("tool.name");
    if (toolName != null) {
        toolArgs = props.getProperty(toolName + ".args", "");
    }
    if (toolProperty == null || askIfUnset && (toolName == null || (argsProperty != null && toolArgs == null))) {
        showGUI(props);
    }
    // finally, return required values, if any
    if (toolProperty != null && !(toolName == null || toolName.equals(""))) {
        p.setProperty(toolProperty, toolName);
        if (argsProperty != null && toolArgs != null)
            p.setProperty(argsProperty, toolArgs);
    }
}
Also used : Project(org.apache.tools.ant.Project) Properties(java.util.Properties)

Example 73 with Project

use of org.apache.tools.ant.Project in project Gargoyle by callakrsos.

the class AntJavaCompilerTest method runtimeAddingTarget.

@Test
public void runtimeAddingTarget() {
    Project p = new Project();
    p.init();
    p.addTarget(extracted(p));
    p.addBuildListener(extracted());
    p.executeTarget("Hello build");
}
Also used : Project(org.apache.tools.ant.Project) Test(org.junit.Test)

Example 74 with Project

use of org.apache.tools.ant.Project in project bnd by bndtools.

the class ExpandPropertiesTask method execute.

@Override
@SuppressWarnings("cast")
public void execute() throws BuildException {
    try {
        if (propertyFile.exists()) {
            Properties properties = new UTF8Properties();
            properties.putAll((Map<?, ?>) getProject().getProperties());
            try (Processor processor = new Processor(properties)) {
                processor.setProperties(propertyFile);
                Project project = getProject();
                Properties flattened = processor.getFlattenedProperties();
                for (Iterator<Object> i = flattened.keySet().iterator(); i.hasNext(); ) {
                    String key = (String) i.next();
                    if (project.getProperty(key) == null) {
                        project.setProperty(key, flattened.getProperty(key));
                    }
                }
            }
        }
        report();
    } catch (IOException e) {
        e.printStackTrace();
        throw new BuildException(e);
    }
}
Also used : Project(org.apache.tools.ant.Project) Processor(aQute.bnd.osgi.Processor) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) Properties(java.util.Properties) UTF8Properties(aQute.lib.utf8properties.UTF8Properties) UTF8Properties(aQute.lib.utf8properties.UTF8Properties)

Example 75 with Project

use of org.apache.tools.ant.Project in project Gargoyle by callakrsos.

the class AntJavaCompiler method parse.

/**
	 *
	 * build.xml파일을 파싱처리하여
	 * 빌드처리 준비상태로 처리한다.
	 * 이후 run 함수를 호출하여 빌드를 실행할 수 있다.
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2017. 3. 7.
	 */
public void parse() {
    p = new Project();
    p.setUserProperty("ant.file", buildFile.getAbsolutePath());
    p.setUserProperty("encoding", encoding.displayName());
    p.init();
    helper = ProjectHelper.getProjectHelper();
    p.addReference("ant.projectHelper", helper);
    if (baseDir != null && baseDir.exists())
        p.setBaseDir(baseDir);
    else
        p.setBaseDir(buildFile.getParentFile());
    //setting console
    DefaultLogger consoleLogger = getLogger();
    consoleLogger.setOutputPrintStream(new PrintStream(out));
    consoleLogger.setErrorPrintStream(new PrintStream(err));
    consoleLogger.setMessageOutputLevel(Project.MSG_VERBOSE);
    p.addBuildListener(consoleLogger);
    //parse build.xml
    helper.parse(p, buildFile);
    LOGGER.debug("  ##### base dir : " + p.getBaseDir());
    LOGGER.debug("  ##### default target : " + p.getDefaultTarget());
    //append build debugger.
    BuildListener buildListener = getBuildListener();
    if (buildListener != null)
        p.addBuildListener(buildListener);
    wasParse = true;
}
Also used : Project(org.apache.tools.ant.Project) PrintStream(java.io.PrintStream) BuildListener(org.apache.tools.ant.BuildListener) DefaultLogger(org.apache.tools.ant.DefaultLogger)

Aggregations

Project (org.apache.tools.ant.Project)80 File (java.io.File)35 BuildException (org.apache.tools.ant.BuildException)23 IOException (java.io.IOException)17 Test (org.junit.Test)13 FileSet (org.apache.tools.ant.types.FileSet)11 ZipFile (java.util.zip.ZipFile)10 IgniteDeploymentGarAntTask (org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask)8 Path (org.apache.tools.ant.types.Path)6 DefaultLogger (org.apache.tools.ant.DefaultLogger)5 ProjectHelper (org.apache.tools.ant.ProjectHelper)5 MissingMethodException (groovy.lang.MissingMethodException)4 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)4 Task (org.apache.tools.ant.Task)4 AbstractProject (hudson.model.AbstractProject)3 Target (org.apache.tools.ant.Target)3 Zip (org.apache.tools.ant.taskdefs.Zip)3 CompilationFailedException (org.codehaus.groovy.control.CompilationFailedException)3 Binding (groovy.lang.Binding)2 GroovyClassLoader (groovy.lang.GroovyClassLoader)2