portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r526019 - in /portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins: ./ src/main/java/org/apache/jetspeed/maven/plugins/
Date Fri, 06 Apr 2007 01:14:02 GMT
Author: ate
Date: Thu Apr  5 18:14:00 2007
New Revision: 526019

URL: http://svn.apache.org/viewvc?view=rev&rev=526019
Log:
Adding preliminary InitDbMojo which already can process configured sql scripts, but not (yet) seed the database using the JetspeedSerializer (will follow later).
Also enhanced the UnpackResourcesMojo and generalized common functionality of both Mojos into a new UnpackResources helper class.
The resources jar isn't specified anymore as project dependency, but will be downloaded (if needed) automatically by the Mojos and then installed in the local repository.

Added:
    portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/InitDbMojo.java   (with props)
    portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/ResourceBundleUnpacker.java   (with props)
    portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SQLScript.java   (with props)
    portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SeedConfig.java   (with props)
    portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResource.java
      - copied, changed from r524048, portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackFolder.java
    portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResources.java   (with props)
Removed:
    portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackFolder.java
Modified:
    portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/pom.xml
    portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResourcesMojo.java

Modified: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/pom.xml?view=diff&rev=526019&r1=526018&r2=526019
==============================================================================
--- portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/pom.xml (original)
+++ portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/pom.xml Thu Apr  5 18:14:00 2007
@@ -47,6 +47,16 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</artifactId>
+      <version>2.0.5</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-downloader</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
       <artifactId>plexus-utils</artifactId>
       <groupId>org.codehaus.plexus</groupId>
       <version>1.4.1</version>

Added: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/InitDbMojo.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/InitDbMojo.java?view=auto&rev=526019
==============================================================================
--- portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/InitDbMojo.java (added)
+++ portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/InitDbMojo.java Thu Apr  5 18:14:00 2007
@@ -0,0 +1,518 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.maven.plugins;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.downloader.Downloader;
+
+/**
+ * @version $Id$
+ * @goal init-db
+ */
+public class InitDbMojo extends AbstractMojo
+{
+    /** The optional resources dependency definition containing (db init) resources to unpack.
+     * @parameter
+     */
+    private UnpackResources unpackResources;
+    
+    /**
+     * @parameter
+     */
+    private SQLScript[] sqlScripts;
+    
+    /**
+     * @parameter
+     */
+    private SeedConfig seedConfig;
+    
+    /**
+     * Database username.  If not given, it will be looked up through 
+     * settings.xml's server with ${settingsKey} as key.
+     * @parameter expression="${username}" 
+     */
+    private String username;
+
+    /**
+     * Database password. If not given, it will be looked up through settings.xml's 
+     * server with ${settingsKey} as key
+     * @parameter expression="${password}" 
+     */
+    private String password;
+
+    /**
+     * @parameter expression="${settings}"
+     * @required
+     * @readonly
+     */
+    private Settings settings;
+    
+    /**
+     * Server's id in settings.xml to look up username and password.
+     * Default to ${url} if not given.
+     * @parameter expression="${settingsKey}" 
+     */
+    private String settingsKey;    
+
+    /**
+     * Database URL
+     * @parameter expression="${url}" 
+     * @required
+     */
+    private String url;
+
+    /**
+     * Database driver classname
+     * @parameter expression="${driver}" 
+     * @required
+     */
+    private String driver;
+
+    /**
+     * @parameter default-value="true"
+     */
+    private boolean escapeProcessing;
+    
+    /**
+     * @parameter default-value=";"
+     */
+    private String sqlDelimiter;
+    
+    /**
+     * @parameter default-value="normal";
+     */
+    private String sqlDelimiterType;
+    
+    /**
+     * When true, skip the execution.
+     * @parameter default-value="false"
+     */
+    private boolean skip;
+    
+    /**
+     * The local repository taken from Maven's runtime. Typically $HOME/.m2/repository.
+     *
+     * @parameter expression="${localRepository}"
+     * @required
+     * @readonly
+     */
+    private ArtifactRepository localRepository;
+
+    /**
+     * The remote repositories used as specified in your POM.
+     *
+     * @parameter expression="${project.repositories}"
+     * @required
+     * @readonly
+     */
+    private List remoteRepositories;
+
+    /** The Maven project.
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    /**
+     * The Maven session.
+     *
+     * @parameter expression="${session}"
+     * @required
+     * @readonly
+     */
+    private MavenSession mavenSession;
+    
+    /**
+     * Artifact downloader.
+     *
+     * @component
+     */
+    private Downloader downloader;
+
+    /**
+     * Artifact repository factory component.
+     *
+     * @component
+     */
+    private ArtifactRepositoryFactory artifactRepositoryFactory;
+    
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        if ( skip )
+        {
+            this.getLog().info( "Skipping initDb" );
+            return;
+        }
+
+        if ( unpackResources != null && !isEmpty(unpackResources.getResourceBundle()) )
+        {
+            File file = ResourceBundleUnpacker.getRemoteResourceBundle(unpackResources.getResourceBundle(), downloader, localRepository, remoteRepositories, artifactRepositoryFactory, mavenSession);
+            if ( isEmpty(unpackResources.getTargetBaseDirectory()) )
+            {
+                unpackResources.setTargetBaseDirectory(project.getBuild().getDirectory());
+            }
+            ResourceBundleUnpacker.unpackResources(file, unpackResources.getTargetBaseDirectory(), unpackResources.getResources(), unpackResources.isOverwrite(), getLog());
+        }
+        
+        if ( (sqlScripts != null && sqlScripts.length > 0) || seedConfig != null )
+        {
+            loadUserInfoFromSettings();
+            
+            // validate connection configuration early
+            Connection connection = getConnection();
+            
+            System.out.println("Running initDb against "+url+" for user "+username);
+            
+            if ( sqlScripts != null )
+            {
+                Statement statement = null;
+                try
+                {
+                    statement = connection.createStatement();
+                    statement.setEscapeProcessing(escapeProcessing);
+
+                    for ( int i = 0; i < sqlScripts.length; i++ )
+                    {
+                        if ( sqlScripts[i] != null )
+                        {
+                            runSqlScript(connection, statement, sqlScripts[i]);
+                        }
+                    }
+                }
+                catch (SQLException e)
+                {
+                    throw new MojoExecutionException("Unexpected SQL exception: ", e);
+                }
+                finally
+                {
+                    if ( statement != null )
+                    {
+                        try
+                        {
+                            statement.close();
+                        }
+                        catch ( SQLException ex )
+                        {
+                            // ignore
+                        }
+                    }
+                    try
+                    {
+                        connection.close();
+                        connection = null;
+                    }
+                    catch ( SQLException ex )
+                    {
+                        // ignore
+                    }
+                    
+                }
+            }
+            if ( connection != null )
+            {
+                try
+                {
+                    connection.close();
+                }
+                catch ( SQLException ex )
+                {
+                    // ignore
+                }
+            }
+        }
+    }
+    
+    /**
+     * read in lines and execute them
+     */
+    private void runSqlScript( Connection connection, Statement statement, SQLScript script ) throws MojoExecutionException
+    {
+        if ( !isEmpty(script.getPath()) )
+        {
+            File scriptFile = new File(script.getPath());
+            if ( !scriptFile.exists() || !scriptFile.isFile() )
+            {
+                throw new MojoExecutionException("SQL script file "+scriptFile.getAbsolutePath()+" not found");
+            }
+            else
+            {
+                getLog().info( "Executing SQL script file: " + scriptFile.getAbsolutePath() );
+                Reader reader = null;
+                try
+                {
+                    reader = new FileReader(scriptFile);
+
+                    StringBuffer sql = new StringBuffer();
+                    String line;
+
+                    BufferedReader in = new BufferedReader( reader );
+
+                    while ( ( line = in.readLine() ) != null )
+                    {
+                        line = line.trim();
+
+                        if ( line.startsWith( "//" ) )
+                        {
+                            continue;
+                        }
+                        if ( line.startsWith( "--" ) )
+                        {
+                            continue;
+                        }
+                        StringTokenizer st = new StringTokenizer( line );
+                        if ( st.hasMoreTokens() )
+                        {
+                            String token = st.nextToken();
+                            if ( "REM".equalsIgnoreCase( token ) )
+                            {
+                                continue;
+                            }
+                        }
+                        sql.append( " " ).append( line );
+
+                        // SQL defines "--" as a comment to EOL
+                        // and in Oracle it may contain a hint
+                        // so we cannot just remove it, instead we must end it
+                        if ( line.indexOf( "--" ) >= 0 )
+                        {
+                            sql.append( "\n" );
+                        }
+                        
+                        if ( ( sqlDelimiterType.equals( "normal" ) && sql.toString().endsWith( sqlDelimiter ) )
+                            || ( sqlDelimiterType.equals( "row" ) && line.equals( sqlDelimiter ) ) )
+                        {
+                            execSQL( connection, statement, sql.substring( 0, sql.length() - sqlDelimiter.length() ), script.isIgnoreErrors() );
+                            sql.replace( 0, sql.length(), "" );
+                        }
+                    }
+                    
+                    // Catch any statements not followed by specified delimiter
+                    if ( !sql.equals( "" ) )
+                    {
+                        execSQL( connection, statement, sql.toString(), script.isIgnoreErrors() );
+                    }
+                }
+                catch (Exception e)
+                {
+                    
+                }
+                finally
+                {
+                    if ( reader != null )
+                    {
+                        try
+                        {
+                            reader.close();
+                        }
+                        catch (Exception e)
+                        {
+                            // ignore
+                        }
+                    }
+                }
+            }
+        }   
+    }
+
+    /**
+     * Exec the sql statement.
+     */
+    private void execSQL( Connection connection, Statement statement, String sql, boolean ignoreErrors ) throws MojoExecutionException
+    {
+        // Check and ignore empty statements
+        if ( "".equals( sql.trim() ) )
+        {
+            return;
+        }
+
+        ResultSet resultSet = null;
+        try
+        {
+            getLog().debug( "SQL: " + sql );
+
+            boolean ret;
+            int updateCount, updateCountTotal = 0;
+
+            ret = statement.execute( sql );
+            updateCount = statement.getUpdateCount();
+            resultSet = statement.getResultSet();
+            do
+            {
+                if ( !ret )
+                {
+                    if ( updateCount != -1 )
+                    {
+                        updateCountTotal += updateCount;
+                    }
+                }
+                ret = statement.getMoreResults();
+                if ( ret )
+                {
+                    updateCount = statement.getUpdateCount();
+                    resultSet = statement.getResultSet();
+                }
+            }
+            while ( ret );
+
+            if ( updateCountTotal > 0)
+            {
+                getLog().debug( updateCountTotal + " rows affected" );
+
+                StringBuffer line = new StringBuffer();
+                line.append( updateCountTotal ).append( " rows affected" );
+                System.out.println( line );
+            }
+
+            SQLWarning warning = connection.getWarnings();
+            while ( warning != null )
+            {
+                getLog().debug( warning + " sql warning" );
+                warning = warning.getNextWarning();
+            }
+            connection.clearWarnings();
+        }
+        catch ( SQLException e )
+        {
+            getLog().error( "Failed to execute: " + sql );
+            if ( !ignoreErrors )
+            {
+                throw new MojoExecutionException("Failed to execute: " + sql, e);
+            }
+            getLog().error( e.toString() );
+        }
+        finally
+        {
+            if ( resultSet != null )
+            {
+                try
+                {
+                    resultSet.close();
+                }
+                catch (SQLException e)
+                {
+                    throw new MojoExecutionException("Unexpected SQL exception: ", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Load username password from settings if user has not set them in JVM properties
+     */
+    private void loadUserInfoFromSettings()
+    {
+        if ( this.settingsKey == null )
+        {
+            this.settingsKey = url;
+        }
+
+        if ( ( username == null || password == null ) && ( settings != null ) )
+        {
+            Server server = settings.getServer( settingsKey );
+
+            if ( server != null )
+            {
+                if ( username == null )
+                {
+                    username = server.getUsername();
+                }
+
+                if ( password == null )
+                {
+                    password = server.getPassword();
+                }
+            }
+        }
+
+        if ( username == null )
+        {
+            username = "";
+        }
+
+        if ( password == null )
+        {
+            password = "";
+        }
+    }
+
+    private Connection getConnection() throws MojoExecutionException
+    {
+        try
+        {
+            getLog().debug( "connecting to " + url );
+            Properties info = new Properties();
+            info.put( "user", username );
+            info.put( "password", password );
+            Driver driverInstance = null;
+            try
+            {
+                Class dc = Class.forName( driver );
+                driverInstance = (Driver) dc.newInstance();
+            }
+            catch ( ClassNotFoundException e )
+            {
+                throw new MojoExecutionException( "Driver class not found: " + driver, e );
+            }
+            catch ( Exception e )
+            {
+                throw new MojoExecutionException( "Failure loading driver: " + driver, e );
+            }
+
+            Connection conn = driverInstance.connect( url, info );
+
+            if ( conn == null )
+            {
+                throw new SQLException( "No suitable Driver for " + url );
+            }
+
+            conn.setAutoCommit( true );
+            return conn;
+        }
+        catch ( SQLException e )
+        {
+            throw new MojoExecutionException( e.getMessage(), e );
+        }
+    }
+
+    private static boolean isEmpty(String value)
+    {
+        return value == null || value.length() == 0;
+    }
+}

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/InitDbMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/InitDbMojo.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/ResourceBundleUnpacker.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/ResourceBundleUnpacker.java?view=auto&rev=526019
==============================================================================
--- portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/ResourceBundleUnpacker.java (added)
+++ portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/ResourceBundleUnpacker.java Thu Apr  5 18:14:00 2007
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.maven.plugins;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.ProjectUtils;
+import org.apache.maven.shared.downloader.DownloadException;
+import org.apache.maven.shared.downloader.DownloadNotFoundException;
+import org.apache.maven.shared.downloader.Downloader;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * @version $Id$
+ *
+ */
+public class ResourceBundleUnpacker
+{
+    public static File getRemoteResourceBundle(String artifactDescriptor, Downloader downloader, ArtifactRepository localRepository, List remoteRepositories, ArtifactRepositoryFactory artifactRepositoryFactory, MavenSession mavenSession) throws MojoExecutionException
+    {
+        // groupId:artifactId:version
+        String[] s = StringUtils.split( artifactDescriptor, ":" );
+
+        if ( s.length != 3 )
+        {
+            throw new MojoExecutionException( "The resource bundle configured must specify a groupId, artifactId, and" 
+                + " version for a remote resource bundle. " 
+                + "Must be of the form <resourceBundle>groupId:artifactId:version</resourceBundle>" );
+        }
+
+        try
+        {
+            return downloader.download( s[0], s[1], s[2], localRepository,
+                                                 ProjectUtils.buildArtifactRepositories( remoteRepositories,
+                                                     artifactRepositoryFactory,
+                                                     mavenSession.getContainer() ) );
+
+        }
+        catch ( DownloadException e )
+        {
+            throw new MojoExecutionException( "Error downloading resources JAR.", e );
+        }
+        catch ( DownloadNotFoundException e )
+        {
+            throw new MojoExecutionException( "Resources JAR cannot be found.", e );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            throw new MojoExecutionException( "Resources JAR cannot be found.", e );
+        }
+    }
+    
+    public static void unpackResources(File resourceBundleFile, String targetBaseDirectory, UnpackResource[] resources, boolean overwrite, Log log) throws MojoExecutionException
+    {
+        File targetBaseDir = new File(targetBaseDirectory);
+        if ( targetBaseDir.exists())
+        {
+            if (!targetBaseDir.isDirectory())
+            throw new MojoExecutionException("Invalid targetBaseDirectory "+targetBaseDir.getAbsolutePath()+": not a directory");
+        }
+        else
+        {
+            targetBaseDir.mkdirs();
+        }
+        
+        UnpackResource[] targetResources = (UnpackResource[])resources.clone();
+        for ( int i = 0; i < targetResources.length; i++ )
+        {
+            resources[i].resolvePaths(i);
+            targetResources[i].setToDir(targetBaseDir.getAbsolutePath()+targetResources[i].getToDir());
+            File toDir = new File(targetResources[i].getToDir());
+            if (toDir.exists())
+            {
+                if (!toDir.isDirectory())
+                {
+                    throw new MojoExecutionException("Invalid resources["+i+"] toDir "+toDir.getAbsolutePath()+": not a directory");
+                }
+            }
+            else
+            {
+                toDir.mkdirs();
+            }
+        }
+        ZipInputStream zis = null;
+        try
+        {
+            zis = new ZipInputStream( new FileInputStream( resourceBundleFile ) );
+            ZipEntry ze = null;
+
+            while ( ( ze = zis.getNextEntry() ) != null )
+            {
+                if (!ze.isDirectory())
+                {
+                    for ( int i = 0; i < resources.length; i++ )
+                    {
+                        UnpackResource ur = resources[i];
+                        if ( (!isEmpty(ur.getFromFile()) && ze.getName().equals(ur.getFromFile())) || (isEmpty(ur.getFromFile()) && ze.getName().startsWith(ur.getFromDir())) )
+                        {
+                            File destFile = null;
+                            if ( !isEmpty(ur.getToFile()) )
+                            {
+                                destFile = new File(ur.getToDir()+ur.getToFile());
+                            }
+                            else
+                            {
+                                destFile = new File(ur.getToDir()+ze.getName().substring(ur.getFromDir().length()));
+                            }
+                            if ( destFile.exists() )
+                            {
+                                if (!destFile.isFile() )
+                                {
+                                    throw new MojoExecutionException("Destination "+destFile.getAbsolutePath()+" already exists and is not a file");
+                                }
+                                if ( destFile.lastModified() >= ze.getTime() || !overwrite )
+                                {
+                                    log.info(ze.getName()+" skipped: already exists at "+destFile.getAbsolutePath());
+                                    continue;
+                                }
+                            }
+                            else
+                            {
+                                destFile.getParentFile().mkdirs();
+                            }
+                            byte[] buffer = new byte[1024];
+                            int length = 0;
+                            FileOutputStream fos = null;
+                            try
+                            {
+                                fos = new FileOutputStream( destFile );
+
+                                while ( ( length =
+                                    zis.read( buffer ) ) >= 0 )
+                                {
+                                    fos.write( buffer, 0, length );
+                                }
+
+                                fos.close();
+                                fos = null;
+                            }
+                            finally
+                            {
+                                if ( fos != null )
+                                {
+                                    try
+                                    {
+                                        fos.close();
+                                    }
+                                    catch ( IOException e )
+                                    {
+                                    }
+                                }
+                            }
+                            destFile.setLastModified(ze.getTime());
+                            log.info(ze.getName()+" extracted to "+destFile.getAbsolutePath());
+                        }
+                    }
+                }
+            }
+        }
+        catch ( IOException ioe )
+        {
+            throw new MojoExecutionException("Error while expanding " + resourceBundleFile.getPath(), ioe);
+        }
+        finally
+        {
+            if ( zis != null )
+            {
+                try
+                {
+                    zis.close();
+                }
+                catch ( IOException e )
+                {
+                }
+            }
+        }
+    }
+    
+    private static boolean isEmpty(String value)
+    {
+        return value == null || value.length() == 0;
+    }
+}

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/ResourceBundleUnpacker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/ResourceBundleUnpacker.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SQLScript.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SQLScript.java?view=auto&rev=526019
==============================================================================
--- portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SQLScript.java (added)
+++ portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SQLScript.java Thu Apr  5 18:14:00 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.maven.plugins;
+
+/**
+ * @version $Id$
+ *
+ */
+public class SQLScript
+{
+    private String path;
+    private boolean ignoreErrors;
+    
+    public boolean isIgnoreErrors()
+    {
+        return ignoreErrors;
+    }
+    public void setIgnoreErrors(boolean ignoreErrors)
+    {
+        this.ignoreErrors = ignoreErrors;
+    }
+    public String getPath()
+    {
+        return path;
+    }
+    public void setPath(String path)
+    {
+        this.path = path;
+    }
+}

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SQLScript.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SQLScript.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SeedConfig.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SeedConfig.java?view=auto&rev=526019
==============================================================================
--- portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SeedConfig.java (added)
+++ portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SeedConfig.java Thu Apr  5 18:14:00 2007
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.maven.plugins;
+
+/**
+ * @version $Id$
+ *
+ */
+public class SeedConfig
+{
+    private String propertiesFile;
+    private String applicationPath;
+    private String bootConfigFiles;
+    private String configFiles;
+    private String logLevel;
+    private String options;
+    
+    public String getApplicationPath()
+    {
+        return applicationPath;
+    }
+    public void setApplicationPath(String applicationPath)
+    {
+        this.applicationPath = applicationPath;
+    }
+    public String getBootConfigFiles()
+    {
+        return bootConfigFiles;
+    }
+    public void setBootConfigFiles(String bootConfigFiles)
+    {
+        this.bootConfigFiles = bootConfigFiles;
+    }
+    public String getConfigFiles()
+    {
+        return configFiles;
+    }
+    public void setConfigFiles(String configFiles)
+    {
+        this.configFiles = configFiles;
+    }
+    public String getLogLevel()
+    {
+        return logLevel;
+    }
+    public void setLogLevel(String logLevel)
+    {
+        this.logLevel = logLevel;
+    }
+    public String getOptions()
+    {
+        return options;
+    }
+    public void setOptions(String options)
+    {
+        this.options = options;
+    }
+    public String getPropertiesFile()
+    {
+        return propertiesFile;
+    }
+    public void setPropertiesFile(String propertiesFile)
+    {
+        this.propertiesFile = propertiesFile;
+    }
+    
+    
+}

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SeedConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/SeedConfig.java
------------------------------------------------------------------------------
    svn:keywords = Id

Copied: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResource.java (from r524048, portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackFolder.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResource.java?view=diff&rev=526019&p1=portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackFolder.java&r1=524048&p2=portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResource.java&r2=526019
==============================================================================
--- portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackFolder.java (original)
+++ portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResource.java Thu Apr  5 18:14:00 2007
@@ -16,29 +16,121 @@
  */
 package org.apache.jetspeed.maven.plugins;
 
+import org.apache.maven.plugin.MojoExecutionException;
+
 /**
  * @version $Id$
  *
  */
-public class UnpackFolder
+public class UnpackResource
 {
-    private String from;
-    private String to;
+    private String fromDir;
+    private String toDir;
+    private String fromFile;
+    private String toFile;
     
-    public String getFrom()
+    public String getFromDir()
     {
-        return from;
+        return fromDir;
     }
-    public void setFrom(String from)
+    public void setFromDir(String from)
     {
-        this.from = from;
+        this.fromDir = from;
     }
-    public String getTo()
+    public String getToDir()
     {
-        return to;
+        return toDir;
     }
-    public void setTo(String to)
+    public void setToDir(String to)
     {
-        this.to = to;
+        this.toDir = to;
+    }
+    public String getFromFile()
+    {
+        return fromFile;
+    }
+    public void setFromFile(String fromFile)
+    {
+        this.fromFile = fromFile;
+    }
+    public String getToFile()
+    {
+        return toFile;
+    }
+    public void setToFile(String toFile)
+    {
+        this.toFile = toFile;
+    }
+    
+    void resolvePaths(int index) throws MojoExecutionException
+    {
+        if ( (isEmpty(fromDir) && isEmpty(fromFile)) || (!isEmpty(fromDir) && !isEmpty(fromFile)) )
+        {
+            throw new MojoExecutionException("Invalid resources["+index+"] specification: fromDir or fromFile must be specified");
+        }
+        if ( (isEmpty(toDir) && isEmpty(toFile)) || (!isEmpty(toDir) && !isEmpty(toFile)) )
+        {
+            throw new MojoExecutionException("Invalid resources["+index+"] specification: toDir or toFile must be specified");
+        }
+        if ( !isEmpty(fromDir) && isEmpty(toDir) )
+        {
+            throw new MojoExecutionException("Invalid resources["+index+"] specification: toDir must be specified when fromDir is specified");
+        }
+        if (!isEmpty(fromFile) )
+        {
+            int lastSlash = fromFile.lastIndexOf('/');
+            if ( lastSlash > -1 )
+            {
+                fromDir = fromFile.substring(0, lastSlash);
+                fromFile = fromFile.substring(lastSlash+1);
+            }
+        }
+        fromDir = getFixedResourceDir(fromDir,false);
+        if ( !isEmpty(fromFile) )
+        {
+            fromFile = fromDir + fromFile;
+        }
+        if ( !isEmpty(toFile) )
+        {
+            int lastSlash = toFile.lastIndexOf('/');
+            if ( lastSlash == -1 )
+            {
+                toDir = "/";
+            }
+            else
+            {
+                toDir = toFile.substring(0, lastSlash);
+                toFile = toFile.substring(lastSlash+1);
+            }
+        }
+        toDir = getFixedResourceDir(toDir,true);
+    }
+    
+    private static String getFixedResourceDir(String resourceDir, boolean firstSlash)
+    {
+        if (!isEmpty(resourceDir))
+        {
+            if ( !resourceDir.endsWith("/") )
+            {
+                resourceDir += "/";
+            }
+            if ( firstSlash )
+            {
+                if ( !resourceDir.startsWith("/") )
+                {
+                    resourceDir = "/" + resourceDir;
+                }
+            }
+            else while ( resourceDir.startsWith("/") )
+            {
+                resourceDir = resourceDir.substring(1);
+            }
+        }
+        return resourceDir;
+    }
+    
+    private static boolean isEmpty(String value)
+    {
+        return value == null || value.length() == 0;
     }
 }

Added: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResources.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResources.java?view=auto&rev=526019
==============================================================================
--- portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResources.java (added)
+++ portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResources.java Thu Apr  5 18:14:00 2007
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.maven.plugins;
+
+/**
+ * @version $Id$
+ *
+ */
+public class UnpackResources
+{
+    private String resourceBundle;
+    private String targetBaseDirectory;
+    private UnpackResource[] resources;
+    private boolean overwrite;
+    
+    public String getResourceBundle()
+    {
+        return resourceBundle;
+    }
+    public void setResourceBundle(String resourceBundle)
+    {
+        this.resourceBundle = resourceBundle;
+    }
+    public UnpackResource[] getResources()
+    {
+        return resources;
+    }
+    public void setResources(UnpackResource[] resources)
+    {
+        this.resources = resources;
+    }
+    public String getTargetBaseDirectory()
+    {
+        return targetBaseDirectory;
+    }
+    public void setTargetBaseDirectory(String targetBaseDirectory)
+    {
+        this.targetBaseDirectory = targetBaseDirectory;
+    }
+    public boolean isOverwrite()
+    {
+        return overwrite;
+    }
+    public void setOverwrite(boolean overwrite)
+    {
+        this.overwrite = overwrite;
+    }
+}

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResources.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResources.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResourcesMojo.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResourcesMojo.java?view=diff&rev=526019&r1=526018&r2=526019
==============================================================================
--- portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResourcesMojo.java (original)
+++ portals/jetspeed-2/branches/J2-M2-REDUX/maven/jetspeed-maven-plugins/src/main/java/org/apache/jetspeed/maven/plugins/UnpackResourcesMojo.java Thu Apr  5 18:14:00 2007
@@ -17,21 +17,19 @@
 package org.apache.jetspeed.maven.plugins;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
+import java.util.List;
 
-import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.downloader.Downloader;
 
 /**
- * UnpackResourcesMojo provides extracting specific folders within a as dependency provided resources jar to specific output folders.
+ * UnpackResourcesMojo provides extracting specific folders within a (remote) resource bundle jar to specific output folders.
  * 
  * @version $Id$
  * @goal unpack-resources
@@ -39,13 +37,12 @@
 public class UnpackResourcesMojo extends AbstractMojo
 {
     
-    /** The name (prefix) of the dependency containing the resources to unpack.
-     * Name must be of form groupId:artifactId:type, like org.apache.portals.jetspeed-2:jetspeed-portal-resources:jar
-     * The only types currently supported are jar and zip.
+    /** The name (prefix) of the (possibly remote) resourceBundle jar containing the resources to unpack.
+     * Name must be of form groupId:artifactId:version, like ${project.groupId}:jetspeed-portal-resources:${project.version}
      * @parameter
      * @required
      */
-    private String resourcesDependencyName;
+    private String resourceBundle;
     
     /**
      * The target base directory where resources will be unpacked to.
@@ -56,7 +53,7 @@
     /**
      * Should existing files be overwritten if older than the resoure file.
      * Existing files newer than the resource file are never overwritten.
-     * @parameter default-value="true"
+     * @parameter default-value="false"
      */
     private boolean overwrite;
     
@@ -64,179 +61,66 @@
      * @parameter
      * @required
      */
-    private UnpackFolder[] resources;
+    private UnpackResource[] resources;
     
+    /**
+     * The local repository taken from Maven's runtime. Typically $HOME/.m2/repository.
+     *
+     * @parameter expression="${localRepository}"
+     * @required
+     * @readonly
+     */
+    private ArtifactRepository localRepository;
+
+    /**
+     * The remote repositories used as specified in your POM.
+     *
+     * @parameter expression="${project.repositories}"
+     * @required
+     * @readonly
+     */
+    private List remoteRepositories;
+
     /** The Maven project.
      * @parameter expression="${project}"
      * @required
      * @readonly
      */
     private MavenProject project;
+
+    /**
+     * The Maven session.
+     *
+     * @parameter expression="${session}"
+     * @required
+     * @readonly
+     */
+    private MavenSession mavenSession;
+    
+    /**
+     * Artifact downloader.
+     *
+     * @component
+     */
+    private Downloader downloader;
+
+    /**
+     * Artifact repository factory component.
+     *
+     * @component
+     */
+    private ArtifactRepositoryFactory artifactRepositoryFactory;
     
     /* (non-Javadoc)
      * @see org.apache.maven.plugin.Mojo#execute()
      */
     public void execute() throws MojoExecutionException, MojoFailureException
     {
-        Artifact resourcesArtifact = getResourcesArtifact();
-        if ( resourcesArtifact == null )
-        {
-            throw new MojoExecutionException("ResourceDependencyName "+resourcesDependencyName+" not defined as project dependency");
-        }
-        File file = resourcesArtifact.getFile();
-        String name = file.getName();
-        if (!name.toLowerCase().endsWith(".jar") && !name.toLowerCase().endsWith(".zip"))
-        {
-            throw new MojoExecutionException("ResourceDependency file "+name+" must be a .jar or .zip file");
-        }
-        
-        File targetBaseDir = new File(targetBaseDirectory);
-        if ( targetBaseDir.exists())
-        {
-            if (!targetBaseDir.isDirectory())
-            throw new MojoExecutionException("Invalid targetBaseDirectory "+targetBaseDir.getAbsolutePath()+": not a directory");
-        }
-        else
-        {
-            targetBaseDir.mkdirs();
-        }
-        
-        UnpackFolder[] targetResources = (UnpackFolder[])resources.clone();
-        for ( int i = 0; i < targetResources.length; i++ )
-        {
-            if ( targetResources[i] == null || isEmpty(targetResources[i].getFrom()) || isEmpty(targetResources[i].getTo()) )
-            {
-                throw new MojoExecutionException("Invalid resources["+i+"] specification: both from and to elements must be defined");
-            }
-            if ( !targetResources[i].getFrom().endsWith("/") )
-            {
-                targetResources[i].setFrom(targetResources[i].getFrom()+"/");
-            }
-            if ( !targetResources[i].getTo().startsWith("/") )
-            {
-                targetResources[i].setTo("/"+targetResources[i].getTo());
-            }
-            if ( !targetResources[i].getTo().endsWith("/") )
-            {
-                targetResources[i].setTo(targetResources[i].getTo()+"/");
-            }
-            targetResources[i].setTo(targetBaseDir.getAbsolutePath()+targetResources[i].getTo());
-            File toDir = new File(targetResources[i].getTo());
-            if (toDir.exists())
-            {
-                if (!toDir.isDirectory())
-                {
-                    throw new MojoExecutionException("Invalid resources to Directory "+toDir.getAbsolutePath()+": not a directory");
-                }
-            }
-            else
-            {
-                toDir.mkdirs();
-            }
-        }
-        unpackFolders(file, targetResources);
-    }
-    
-    private boolean isEmpty(String value)
-    {
-        return value == null || value.length() == 0;
-    }
-    
-    private void unpackFolders(File resourcesFile, UnpackFolder[] resources) throws MojoExecutionException
-    {
-        ZipInputStream zis = null;
-        try
-        {
-            zis = new ZipInputStream( new FileInputStream( resourcesFile ) );
-            ZipEntry ze = null;
-
-            while ( ( ze = zis.getNextEntry() ) != null )
-            {
-                if (!ze.isDirectory())
-                {
-                    for ( int i = 0; i < resources.length; i++ )
-                    {
-                        if ( ze.getName().startsWith(resources[i].getFrom()) )
-                        {
-                            File destFile = new File(resources[i].getTo()+ze.getName().substring(resources[i].getFrom().length()));
-                            if ( destFile.exists() )
-                            {
-                                if (!destFile.isFile() )
-                                {
-                                    throw new MojoExecutionException("Destination "+destFile.getAbsolutePath()+" already exists and is not a file");
-                                }
-                                if ( destFile.lastModified() >= ze.getTime() || !overwrite )
-                                {
-                                    getLog().info(ze.getName()+" skipped: already exists at "+destFile.getAbsolutePath());
-                                    continue;
-                                }
-                            }
-                            destFile.getParentFile().mkdirs();
-                            byte[] buffer = new byte[1024];
-                            int length = 0;
-                            FileOutputStream fos = null;
-                            try
-                            {
-                                fos = new FileOutputStream( destFile );
-
-                                while ( ( length =
-                                    zis.read( buffer ) ) >= 0 )
-                                {
-                                    fos.write( buffer, 0, length );
-                                }
-
-                                fos.close();
-                                fos = null;
-                            }
-                            finally
-                            {
-                                if ( fos != null )
-                                {
-                                    try
-                                    {
-                                        fos.close();
-                                    }
-                                    catch ( IOException e )
-                                    {
-                                    }
-                                }
-                            }
-                            destFile.setLastModified(ze.getTime());
-                            getLog().info(ze.getName()+" extracted to "+destFile.getAbsolutePath());
-                        }
-                    }
-                }
-            }
-        }
-        catch ( IOException ioe )
-        {
-            throw new MojoExecutionException("Error while expanding " + resourcesFile.getPath(), ioe);
-        }
-        finally
-        {
-            if ( zis != null )
-            {
-                try
-                {
-                    zis.close();
-                }
-                catch ( IOException e )
-                {
-                }
-            }
-        }
-    }
-    
-    private Artifact getResourcesArtifact() {
-        Iterator iter = project.getArtifacts().iterator();
-        while ( iter.hasNext() )
+        if ( targetBaseDirectory == null || targetBaseDirectory.length() == 0 )
         {
-            Artifact a = (Artifact)iter.next();
-            if ( a.toString().startsWith(resourcesDependencyName) )
-            {
-                return a;
-            }
+            targetBaseDirectory = project.getBuild().getDirectory();
         }
-        return null;
+        File file = ResourceBundleUnpacker.getRemoteResourceBundle(resourceBundle, downloader, localRepository, remoteRepositories, artifactRepositoryFactory, mavenSession);
+        ResourceBundleUnpacker.unpackResources(file, targetBaseDirectory, resources, overwrite, getLog());
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message