Search in sources :

Example 31 with Project

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

the class GridToolsSelfTest method testAntGarTaskWithExternalP2PDescriptor.

/**
 * @throws Exception If failed.
 */
public void testAntGarTaskWithExternalP2PDescriptor() throws Exception {
    String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir");
    String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir");
    String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_1";
    String metaDirName = baseDirName + File.separator + "META-INF";
    String garFileName = baseDirName + ".gar";
    String garDescrDirName = U.resolveIgnitePath(GridTestProperties.getProperty("ant.gar.descriptor.dir")).getAbsolutePath();
    // Make base and META-INF dir.
    boolean mkdir = new File(baseDirName).mkdirs();
    assert mkdir;
    mkdir = new File(metaDirName).mkdirs();
    assert mkdir;
    // Copy files to basedir
    U.copy(new File(srcDirName), new File(baseDirName), true);
    IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask();
    Project garProject = new Project();
    garProject.setName("Gar test project");
    garTask.setDestFile(new File(garFileName));
    garTask.setDescrdir(new File(garDescrDirName));
    garTask.setBasedir(new File(baseDirName));
    garTask.setProject(garProject);
    garTask.execute();
    File garFile = new File(garFileName);
    assert garFile.exists();
    boolean res = checkStructure(garFile, true);
    assert res;
}
Also used : Project(org.apache.tools.ant.Project) IgniteDeploymentGarAntTask(org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Example 32 with Project

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

the class GridToolsSelfTest method testAntGarTaskWithNullDescriptor.

/**
 * @throws Exception If failed.
 */
@SuppressWarnings({ "TypeMayBeWeakened" })
public void testAntGarTaskWithNullDescriptor() throws Exception {
    String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir");
    String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir");
    String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_4";
    String metaDirName = baseDirName + File.separator + "META-INF";
    String garFileName = baseDirName + ".gar";
    // Make base and META-INF dir.
    boolean mkdir = new File(baseDirName).mkdirs();
    assert mkdir;
    mkdir = new File(metaDirName).mkdirs();
    assert mkdir;
    // Copy files to basedir
    U.copy(new File(srcDirName), new File(baseDirName), true);
    IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask();
    Project garProject = new Project();
    garProject.setName("Gar test project");
    garTask.setDestFile(new File(garFileName));
    garTask.setBasedir(new File(baseDirName));
    garTask.setProject(garProject);
    try {
        garTask.execute();
    } catch (BuildException e) {
        if (log().isInfoEnabled())
            log().info(e.getMessage());
        assert false;
    }
}
Also used : Project(org.apache.tools.ant.Project) IgniteDeploymentGarAntTask(org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Example 33 with Project

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

the class CayenneGeneratorTaskCrossMapRelationshipsTest method testCrossDataMapRelationships.

/**
 * Tests pairs generation with a cross-DataMap relationship.
 */
@Test
public void testCrossDataMapRelationships() throws Exception {
    CayenneGeneratorTask task = new CayenneGeneratorTask();
    task.setProject(new Project());
    task.setTaskName("Test");
    task.setLocation(Location.UNKNOWN_LOCATION);
    // prepare destination directory
    File destDir = new File(FileUtil.baseTestDirectory(), "cgen12");
    // prepare destination directory
    if (!destDir.exists()) {
        assertTrue(destDir.mkdirs());
    }
    File map = new File(destDir, "cgen-dependent.map.xml");
    ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen-dependent.map.xml", map);
    File[] additionalMaps = new File[1];
    additionalMaps[0] = new File(destDir, "cgen.map.xml");
    ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen.map.xml", additionalMaps[0]);
    FileList additionalMapsFilelist = new FileList();
    additionalMapsFilelist.setDir(additionalMaps[0].getParentFile());
    additionalMapsFilelist.setFiles(additionalMaps[0].getName());
    Path additionalMapsPath = new Path(task.getProject());
    additionalMapsPath.addFilelist(additionalMapsFilelist);
    // setup task
    task.setMap(map);
    task.setAdditionalMaps(additionalMapsPath);
    task.setMakepairs(true);
    task.setOverwrite(false);
    task.setMode("entity");
    task.setIncludeEntities("MyArtGroup");
    task.setDestDir(destDir);
    task.setSuperpkg("org.apache.cayenne.testdo.cgen2.auto");
    task.setUsepkgpath(true);
    // run task
    task.execute();
    // check results
    File a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/MyArtGroup.java"));
    assertTrue(a.isFile());
    assertContents(a, "MyArtGroup", "org.apache.cayenne.testdo.cgen2", "_MyArtGroup");
    File _a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/auto/_MyArtGroup.java"));
    assertTrue(_a.exists());
    assertContents(_a, "_MyArtGroup", "org.apache.cayenne.testdo.cgen2.auto", "BaseDataObject");
    assertContents(_a, "import org.apache.cayenne.testdo.testmap.ArtGroup;");
    assertContents(_a, " ArtGroup getToParentGroup()");
    assertContents(_a, "setToParentGroup(ArtGroup toParentGroup)");
}
Also used : Path(org.apache.tools.ant.types.Path) Project(org.apache.tools.ant.Project) FileList(org.apache.tools.ant.types.FileList) File(java.io.File) Test(org.junit.Test)

Example 34 with Project

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

the class CayenneGeneratorTaskTest method setUp.

@Before
public void setUp() {
    Project project = new Project();
    project.setBaseDir(baseDir);
    task = new CayenneGeneratorTask();
    task.setProject(project);
    task.setTaskName("Test");
    task.setLocation(Location.UNKNOWN_LOCATION);
}
Also used : Project(org.apache.tools.ant.Project) Before(org.junit.Before)

Example 35 with Project

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

the class DbImporterTaskTest method getCdbImport.

private DbImporterTask getCdbImport(String buildFile) {
    Project project = new Project();
    File map = distDir(buildFile);
    ResourceUtil.copyResourceToFile(getPackagePath() + "/" + buildFile, map);
    ProjectHelper.configureProject(project, map);
    UnknownElement task = (UnknownElement) project.getTargets().get("dist").getTasks()[0];
    task.maybeConfigure();
    return (DbImporterTask) task.getRealThing();
}
Also used : Project(org.apache.tools.ant.Project) UnknownElement(org.apache.tools.ant.UnknownElement) File(java.io.File)

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