Search in sources :

Example 66 with Project

use of org.apache.tools.ant.Project in project intellij-community by JetBrains.

the class Javac2 method buildClasspathClassLoader.

/**
   * Create class loader based on classpath, bootclasspath, and sourcepath.
   *
   * @return a URL classloader
   */
private InstrumentationClassFinder buildClasspathClassLoader() {
    final StringBuffer classPathBuffer = new StringBuffer();
    final Project project = getProject();
    final Path cp = new Path(project);
    appendPath(cp, getBootclasspath());
    cp.setLocation(getDestdir().getAbsoluteFile());
    appendPath(cp, getClasspath());
    appendPath(cp, getSourcepath());
    appendPath(cp, getSrcdir());
    if (getIncludeantruntime()) {
        cp.addExisting(cp.concatSystemClasspath("last"));
    }
    boolean shouldInclude = getIncludejavaruntime();
    if (!shouldInclude) {
        if (project != null) {
            final String propValue = project.getProperty(PROPERTY_INSTRUMENTATION_INCLUDE_JAVA_RUNTIME);
            shouldInclude = !("false".equalsIgnoreCase(propValue) || "no".equalsIgnoreCase(propValue));
        } else {
            shouldInclude = true;
        }
    }
    if (shouldInclude) {
        cp.addJavaRuntime();
    }
    cp.addExtdirs(getExtdirs());
    final String[] pathElements = cp.list();
    for (int i = 0; i < pathElements.length; i++) {
        final String pathElement = pathElements[i];
        classPathBuffer.append(File.pathSeparator);
        classPathBuffer.append(pathElement);
    }
    final String classPath = classPathBuffer.toString();
    log("classpath=" + classPath, Project.MSG_VERBOSE);
    try {
        return createInstrumentationClassFinder(classPath);
    } catch (MalformedURLException e) {
        fireError(e.getMessage());
        return null;
    }
}
Also used : Path(org.apache.tools.ant.types.Path) Project(org.apache.tools.ant.Project) MalformedURLException(java.net.MalformedURLException)

Example 67 with Project

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

the class MavenDependencyResolverTest method setUp.

@Before
public void setUp() {
    dependenciesTask = spy(new DependenciesTask());
    doNothing().when(dependenciesTask).execute();
    doAnswer(new Answer() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            invocationOnMock.callRealMethod();
            Object[] args = invocationOnMock.getArguments();
            project = (Project) args[0];
            project.setProperty("group1:artifact1:jar", "path1");
            project.setProperty("group2:artifact2:jar", "path2");
            project.setProperty("group3:artifact3:jar:classifier3", "path3");
            return null;
        }
    }).when(dependenciesTask).setProject(any(Project.class));
}
Also used : DependenciesTask(org.apache.maven.artifact.ant.DependenciesTask) Answer(org.mockito.stubbing.Answer) Project(org.apache.tools.ant.Project) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Before(org.junit.Before)

Example 68 with Project

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

the class AntBuildFileTestBase method setupProject.

protected void setupProject(File projectFile) {
    try {
        restoreSysout = System.out;
        restoreSyserr = System.err;
        output = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(output, true, "UTF-8");
        System.setOut(ps);
        System.setErr(ps);
        project = new Project();
        project.init();
        project.setUserProperty(MagicNames.ANT_FILE, projectFile.getAbsolutePath());
        ProjectHelper.configureProject(project, projectFile);
        listener = new DefaultLogger();
        listener.setMessageOutputLevel(Project.MSG_DEBUG);
        listener.setErrorPrintStream(ps);
        listener.setOutputPrintStream(ps);
        getProject().addBuildListener(listener);
        DefaultLogger console = new DefaultLogger();
        console.setMessageOutputLevel(Project.MSG_INFO);
        console.setErrorPrintStream(restoreSyserr);
        console.setOutputPrintStream(restoreSysout);
        getProject().addBuildListener(console);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : PrintStream(java.io.PrintStream) Project(org.apache.tools.ant.Project) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) DefaultLogger(org.apache.tools.ant.DefaultLogger)

Example 69 with Project

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

the class CreateZipFile method zipFolder.

/**
	* Zip the srcFolder into the destFileZipFile. All the folder subtree of the src folder is added to the destZipFile
	* archive.
	* 
	*
	* @param srcFolder File, the path of the srcFolder
	* @param destZipFile File, the path of the destination zipFile. This file will be created or erased.
	*/
public static void zipFolder(File srcFolder, File destZipFile, String includesdir) {
    Zip zipper = new Zip();
    zipper.setDestFile(destZipFile);
    zipper.setBasedir(srcFolder);
    zipper.setIncludes(includesdir);
    zipper.setUpdate(true);
    zipper.setCompress(true);
    zipper.setCaseSensitive(false);
    zipper.setFilesonly(false);
    zipper.setTaskName("zip");
    zipper.setTaskType("zip");
    zipper.setProject(new Project());
    zipper.setOwningTarget(new Target());
    zipper.execute();
    System.out.println(destZipFile);
}
Also used : GZip(org.apache.tools.ant.taskdefs.GZip) Zip(org.apache.tools.ant.taskdefs.Zip) Project(org.apache.tools.ant.Project) Target(org.apache.tools.ant.Target)

Example 70 with Project

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

the class EsaTaskTest method generateArchiveNoManifest.

@Test
public void generateArchiveNoManifest() {
    File srcDir = new File("../src/test/resources");
    File destfile = new File("target/esa-test1.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.execute();
    assertTrue(destfile.exists());
    try {
        ZipFile esaArchive = new ZipFile(destfile);
        assertNotNull(esaArchive);
        ZipEntry subsystemManifest = esaArchive.getEntry("OSGI-INF/SUBSYSTEM.MF");
        assertNull(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)

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