001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.util.ant;
016    
017    import java.io.File;
018    
019    import org.apache.tools.ant.Project;
020    import org.apache.tools.ant.taskdefs.War;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class WarTask {
026    
027            public static void war(
028                    File baseDir, File destination, String excludes, File webxml) {
029    
030                    Project project = AntUtil.getProject();
031    
032                    War war = new War();
033    
034                    war.setBasedir(baseDir);
035                    war.setDestFile(destination);
036                    war.setExcludes(excludes);
037    
038                    File manifestFile = new File(
039                            baseDir.getAbsolutePath() + "/META-INF/MANIFEST.MF");
040    
041                    if (manifestFile.exists()) {
042                            war.setManifest(manifestFile);
043                    }
044    
045                    war.setProject(project);
046                    war.setWebxml(webxml);
047    
048                    war.execute();
049            }
050    
051            public static void war(
052                    String baseDir, String destination, String excludes, String webxml) {
053    
054                    war(
055                            new File(baseDir), new File(destination), excludes,
056                            new File(webxml));
057            }
058    
059    }