/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.tool.xar;

import java.io.File;
import java.util.Collection;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;

/**
 * Common code for the Verify and Format Mojos.
 *
 * @version $Id$
 * @since 4.0M2
 */
public abstract class AbstractVerifyMojo extends AbstractXARMojo
{
    /**
     * Admin author for creator/contentAuthor and author.
     */
    protected static final String AUTHOR = "xwiki:XWiki.Admin";

    /**
     * First version.
     */
    protected static final String VERSION = "1.1";

    /**
     * If true then don't check if the packaging is XAR before running mojos.
     *
     * @parameter expression="${force}"
     * @readonly
     */
    protected boolean force;

    /**
     * @return the list of XAR XML files in this project
     */
    protected Collection<File> getXARXMLFiles()
    {
        // Find all files in the resources dir
        File resourcesDir = getResourcesDirectory();

        // Filter package.xml and files not ending with .xml
        Collection<File> files = FileUtils.listFiles(resourcesDir,
            FileFilterUtils.and(
                FileFilterUtils.suffixFileFilter(".xml"),
                FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(PACKAGE_XML))),
            TrueFileFilter.INSTANCE);
        return files;
    }
}

@@ -965,16 +965,46 @@
 lection;
+%0Aimport java.util.Collections;
 %0A%0Aimport
@@ -2048,16 +2048,98 @@
  files =
+ Collections.emptyList();%0A        if (resourcesDir.exists()) %7B%0A            files =
  FileUti
@@ -2169,32 +2169,36 @@
 ir,%0A            
+    
 FileFilterUtils.
@@ -2202,16 +2202,20 @@
 ls.and(%0A
+    
         
@@ -2264,16 +2264,20 @@
 .xml%22),%0A
+    
         
@@ -2373,16 +2373,20 @@
         
+  
+  
 TrueFile
@@ -2403,16 +2403,27 @@
 TANCE);%0A
+        %7D%0A%0A
         

Add new Verify and Format Mojos in XAR plugin * Make it more foolproof