Package org.apache.tools.ant.taskdefs

Examples of org.apache.tools.ant.taskdefs.War


        File userWebXML = getWebXML(userWebFilesDir);
        IClasspathEntry[] jarEntries = getJarEntries();
        File userClassFilesDir = getAbsoluteOutputLocation(this.javaProject);
       
        outputWar.delete();
        War warTask = new War();
        progressMonitor.worked(1);
        Project antProject = new Project();
        antProject.init();
        warTask.setProject(antProject);
        warTask.setDestFile(outputWar);
        ZipFileSet classes = new ZipFileSet();
        classes.setDir(userClassFilesDir);
        warTask.addClasses(classes);
        classes = new ZipFileSet();
        classes.setDir(userClassFilesDir);
        classes.setIncludes("log4j.properties");
        warTask.addClasses(classes);
        if (userWebFilesDir != null && userWebFilesDir.exists())
        {
            FileSet webFiles = new FileSet();
            webFiles.setDir(userWebFilesDir);
            webFiles.setExcludes(WEBINF);
            warTask.addFileset(webFiles);
        }
        if (userWebXML != null && userWebXML.exists())
        {
            warTask.setWebxml(userWebXML);
        }
        else
        {
            // Without a webxml attribute the Ant war task
            // requires the update attribute set to true
            // That's why we actually need an existing war file.
            try
            {
                // A file is needed for war creation
                File voidFile = File.createTempFile("void", null);
                createZipFile(outputWar, voidFile);
                voidFile.delete();
            }
            catch (IOException e)
            {
                throw new CoreException(
                    new Status(
                        IStatus.ERROR,
                        WebappPlugin.getPluginId(),
                        IStatus.OK,
                        WebappMessages.getString(
                            "WarBuilder.message.createwar.temp"),
                        e));
            }

            warTask.setUpdate(true);
        }

        ZipFileSet[] jarFS = getZipFileSets(jarEntries);
        for (int i = 0; i < jarFS.length; i++)
        {
            warTask.addLib(jarFS[i]);
        }
        warTask.execute();
        progressMonitor.worked(2);
        return outputWar;
    }
View Full Code Here


        createWar();
    }

    private void createWar() {
        War war = new War();
        war.setDestFile(destDir.resolve(processName + ".war").toFile());
        war.setNeedxmlfile(false);

        FileSet set = new FileSet();
        set.setDir(destDir.toFile());
        war.add(set);

        war.setTaskName("war");
        war.setProject(AntUtil.builder().getProject());

        war.execute();
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.taskdefs.War

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.