diff options
author | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-10-21 14:58:47 +0200 |
---|---|---|
committer | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-10-21 14:58:47 +0200 |
commit | 7396da3bdfd34c03e92a88f91be526106bd737c6 (patch) | |
tree | fbb1d328a6ebb34f44593fb6ceb44722769181dc /src/main | |
parent | ba12beea79817971caa6f0c9a6e9afa3afde7fa4 (diff) | |
download | maven-nar-plugin-7396da3bdfd34c03e92a88f91be526106bd737c6.tar.gz maven-nar-plugin-7396da3bdfd34c03e92a88f91be526106bd737c6.tar.bz2 maven-nar-plugin-7396da3bdfd34c03e92a88f91be526106bd737c6.tar.xz maven-nar-plugin-7396da3bdfd34c03e92a88f91be526106bd737c6.zip |
Fixed NAR-82; Better fix for NAR-77
Diffstat (limited to 'src/main')
6 files changed, 135 insertions, 49 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java index 31d9960..c3640cc 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java @@ -72,50 +72,76 @@ public abstract class AbstractResourcesMojo */ private ArchiverManager archiverManager; - protected void copyResources( File srcDir, String aol) - throws MojoExecutionException, MojoFailureException + protected int copyIncludes( File srcDir ) throws IOException { int copied = 0; - try + + // copy includes + File includeDir = new File( srcDir, resourceIncludeDir ); + if ( includeDir.exists() ) { - // copy headers - File includeDir = new File( srcDir, resourceIncludeDir ); - if ( includeDir.exists() ) - { - File includeDstDir = new File( getTargetDirectory(), "include" ); - copied += NarUtil.copyDirectoryStructure( includeDir, includeDstDir, null, NarUtil.DEFAULT_EXCLUDES ); - } + File includeDstDir = new File( getTargetDirectory(), "include" ); + copied += NarUtil.copyDirectoryStructure( includeDir, includeDstDir, null, NarUtil.DEFAULT_EXCLUDES ); + } + + return copied; + } - // copy binaries - File binDir = new File( srcDir, resourceBinDir ); - if ( binDir.exists() ) - { - File binDstDir = new File( getTargetDirectory(), "bin" ); - binDstDir = new File( binDstDir, aol ); + protected int copyBinaries( File srcDir, String aol ) + throws IOException { + int copied = 0; + + // copy binaries + File binDir = new File( srcDir, resourceBinDir ); + if ( binDir.exists() ) + { + File binDstDir = new File( getTargetDirectory(), "bin" ); + binDstDir = new File( binDstDir, aol ); - copied += NarUtil.copyDirectoryStructure( binDir, binDstDir, null, NarUtil.DEFAULT_EXCLUDES ); - } + copied += NarUtil.copyDirectoryStructure( binDir, binDstDir, null, NarUtil.DEFAULT_EXCLUDES ); + } - // copy libraries - File libDir = new File( srcDir, resourceLibDir ); - if ( libDir.exists() ) + return copied; + } + + protected int copyLibraries( File srcDir, String aol) throws MojoFailureException, IOException { + int copied = 0; + + // copy libraries + File libDir = new File( srcDir, resourceLibDir ); + if ( libDir.exists() ) + { + // create all types of libs + for ( Iterator i = getLibraries().iterator(); i.hasNext(); ) { - // create all types of libs - for ( Iterator i = getLibraries().iterator(); i.hasNext(); ) - { - Library library = (Library) i.next(); - String type = library.getType(); - File libDstDir = new File( getTargetDirectory(), "lib" ); - libDstDir = new File( libDstDir, aol ); - libDstDir = new File( libDstDir, type ); + Library library = (Library) i.next(); + String type = library.getType(); + File libDstDir = new File( getTargetDirectory(), "lib" ); + libDstDir = new File( libDstDir, aol ); + libDstDir = new File( libDstDir, type ); - // filter files for lib - String includes = - "**/*." - + NarUtil.getDefaults().getProperty( NarUtil.getAOLKey( aol ) + "." + type + ".extension" ); - copied += NarUtil.copyDirectoryStructure( libDir, libDstDir, includes, NarUtil.DEFAULT_EXCLUDES ); - } + // filter files for lib + String includes = + "**/*." + + NarUtil.getDefaults().getProperty( NarUtil.getAOLKey( aol ) + "." + type + ".extension" ); + copied += NarUtil.copyDirectoryStructure( libDir, libDstDir, includes, NarUtil.DEFAULT_EXCLUDES ); } + } + + return copied; + } + + protected void copyResources( File srcDir, String aol ) + throws MojoExecutionException, MojoFailureException + { + int copied = 0; + try + { + copied += copyIncludes( srcDir ); + + copied += copyBinaries( srcDir, aol); + + copied += copyLibraries( srcDir, aol ); // unpack jar files File classesDirectory = new File( getOutputDirectory(), "classes" ); diff --git a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java index 47c6f76..6b55e60 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java @@ -47,7 +47,7 @@ import org.codehaus.plexus.util.StringUtils; * Compiles native source files. * * @goal nar-compile - * @phase process-classes + * @phase compile * @requiresDependencyResolution compile * @author Mark Donszelmann */ diff --git a/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java index c8ec983..a0cf60a 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java @@ -61,7 +61,9 @@ public class NarGnuConfigureMojo if ( shouldSkip() ) return; - // always copy, in case we need libs or include dirs + if ( !useGnu() ) + return; + File targetDir = getGnuAOLSourceDirectory(); if ( gnuSourceDirectory.exists() ) { @@ -76,13 +78,7 @@ public class NarGnuConfigureMojo { throw new MojoExecutionException( "Failed to copy GNU sources", e ); } - } - if ( !useGnu() ) - return; - - if ( targetDir.exists() ) - { File autogen = new File( targetDir, AUTOGEN ); if ( !gnuConfigureSkip && !gnuAutogenSkip && autogen.exists() ) { diff --git a/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java b/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java new file mode 100644 index 0000000..ca914c6 --- /dev/null +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java @@ -0,0 +1,63 @@ +package org.apache.maven.plugin.nar; + +/* + * 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. + */ + +import java.io.IOException; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + +/** + * Move the GNU style include/lib to some output directory + * + * @goal nar-gnu-resources + * @phase process-resources + * @requiresProject + * @author Mark Donszelmann + */ +public class NarGnuResources + extends AbstractGnuMojo +{ + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( shouldSkip() ) + return; + + if ( gnuSourceDirectory.exists() ) + { + int copied = 0; + + try + { + copied += copyIncludes( gnuSourceDirectory ); + } + catch ( IOException e ) + { + throw new MojoFailureException( "NAR: Gnu could not copy resources", e ); + } + + if (copied > 0) { + getLog().info( "Copied "+copied+" GNU resources" ); + } + + } + } +} diff --git a/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java index ebdb104..2c2a9b1 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java @@ -60,14 +60,14 @@ public class NarResourcesMojo if ( shouldSkip() ) return; - // scan for AOLs + // scan resourceDirectory for AOLs File aolDir = new File( resourceDirectory, "aol" ); if ( aolDir.exists() ) { String[] aol = aolDir.list(); for ( int i = 0; i < aol.length; i++ ) { - // copy onky resources of current AOL + // copy only resources of current AOL if ( resourcesCopyAOL && ( !aol[i].equals( getAOL().toString() ) ) ) continue; diff --git a/src/main/resources/META-INF/plexus/components.xml b/src/main/resources/META-INF/plexus/components.xml index 51afa51..cb10014 100644 --- a/src/main/resources/META-INF/plexus/components.xml +++ b/src/main/resources/META-INF/plexus/components.xml @@ -33,12 +33,13 @@ under the License. org.apache.maven.plugins:maven-nar-plugin:nar-gnu-configure</process-sources> <generate-resources></generate-resources> <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources, - org.apache.maven.plugins:maven-nar-plugin:nar-resources</process-resources> + org.apache.maven.plugins:maven-nar-plugin:nar-resources, + org.apache.maven.plugins:maven-nar-plugin:nar-gnu-resources</process-resources> <compile>org.apache.maven.plugins:maven-compiler-plugin:compile, org.apache.maven.plugins:maven-nar-plugin:nar-javah, - org.apache.maven.plugins:maven-nar-plugin:nar-gnu-make</compile> - <process-classes>org.apache.maven.plugins:maven-nar-plugin:nar-compile, - org.apache.maven.plugins:maven-nar-plugin:nar-gnu-process</process-classes> + org.apache.maven.plugins:maven-nar-plugin:nar-gnu-make, + org.apache.maven.plugins:maven-nar-plugin:nar-compile</compile> + <process-classes>org.apache.maven.plugins:maven-nar-plugin:nar-gnu-process</process-classes> <generate-test-sources></generate-test-sources> <process-test-sources></process-test-sources> <generate-test-resources></generate-test-resources> |