summaryrefslogtreecommitdiff
path: root/src/main/java/org/apache/maven/plugin/nar/Javah.java
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-06 14:44:29 +0200
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-06 14:44:29 +0200
commit3dca89f0015613ab3f287945965e9f92a6079cd8 (patch)
treea00619a63c55b74c16ac8116d04b21f322e1747b /src/main/java/org/apache/maven/plugin/nar/Javah.java
parent75b9fcffc6709f9c65990f6d04d593d3bfb4743d (diff)
downloadmaven-nar-plugin-3dca89f0015613ab3f287945965e9f92a6079cd8.tar.gz
maven-nar-plugin-3dca89f0015613ab3f287945965e9f92a6079cd8.tar.bz2
maven-nar-plugin-3dca89f0015613ab3f287945965e9f92a6079cd8.tar.xz
maven-nar-plugin-3dca89f0015613ab3f287945965e9f92a6079cd8.zip
Reformat all source files and add licenses to tests
Diffstat (limited to 'src/main/java/org/apache/maven/plugin/nar/Javah.java')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Javah.java243
1 files changed, 142 insertions, 101 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/Javah.java b/src/main/java/org/apache/maven/plugin/nar/Javah.java
index 6909846..a563093 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Javah.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Javah.java
@@ -43,67 +43,66 @@ import org.codehaus.plexus.util.StringUtils;
/**
* Sets up the javah configuration
- *
+ *
* @author Mark Donszelmann
*/
-public class Javah {
+public class Javah
+{
/**
* Javah command to run.
- *
+ *
* @parameter default-value="javah"
*/
private String name = "javah";
/**
* Add boot class paths. By default none.
- *
+ *
* @parameter
*/
- private List/*<File>*/ bootClassPaths = new ArrayList();
-
+ private List/* <File> */bootClassPaths = new ArrayList();
+
/**
* Add class paths. By default the classDirectory directory is included and all dependent classes.
- *
+ *
* @parameter
*/
- private List/*<File>*/ classPaths = new ArrayList();
-
+ private List/* <File> */classPaths = new ArrayList();
+
/**
* The target directory into which to generate the output.
- *
+ *
* @parameter expression="${project.build.directory}/nar/javah-include"
* @required
*/
private File jniDirectory;
-
+
/**
* The class directory to scan for class files with native interfaces.
- *
+ *
* @parameter expression="${project.build.directory}/classes"
* @required
*/
private File classDirectory;
/**
- * The set of files/patterns to include
- * Defaults to "**\/*.class"
- *
+ * The set of files/patterns to include Defaults to "**\/*.class"
+ *
* @parameter
*/
private Set includes = new HashSet();
/**
* A list of exclusion filters.
- *
+ *
* @parameter
*/
private Set excludes = new HashSet();
/**
- * The granularity in milliseconds of the last modification
- * date for testing whether a source needs recompilation
- *
+ * The granularity in milliseconds of the last modification date for testing whether a source needs recompilation
+ *
* @parameter default-value="0"
* @required
*/
@@ -122,133 +121,175 @@ public class Javah {
* @parameter
*/
private File timestampFile;
-
+
private AbstractCompileMojo mojo;
-
- public Javah() {
+
+ public Javah()
+ {
}
- public void setAbstractCompileMojo(AbstractCompileMojo mojo) {
- this.mojo = mojo;
- }
-
- protected List getClassPaths() throws MojoExecutionException {
- if (classPaths.isEmpty()) {
- try {
- classPaths.addAll(mojo.getMavenProject().getCompileClasspathElements());
- } catch (DependencyResolutionRequiredException e) {
- throw new MojoExecutionException("JAVAH, cannot get classpath", e);
+ public void setAbstractCompileMojo( AbstractCompileMojo mojo )
+ {
+ this.mojo = mojo;
+ }
+
+ protected List getClassPaths()
+ throws MojoExecutionException
+ {
+ if ( classPaths.isEmpty() )
+ {
+ try
+ {
+ classPaths.addAll( mojo.getMavenProject().getCompileClasspathElements() );
+ }
+ catch ( DependencyResolutionRequiredException e )
+ {
+ throw new MojoExecutionException( "JAVAH, cannot get classpath", e );
}
}
return classPaths;
}
- protected File getJniDirectory() {
- if (jniDirectory == null) {
- jniDirectory = new File(mojo.getMavenProject().getBuild().getDirectory(), "nar/javah-include");
+ protected File getJniDirectory()
+ {
+ if ( jniDirectory == null )
+ {
+ jniDirectory = new File( mojo.getMavenProject().getBuild().getDirectory(), "nar/javah-include" );
}
return jniDirectory;
}
-
- protected File getClassDirectory() {
- if (classDirectory == null) {
- classDirectory = new File(mojo.getMavenProject().getBuild().getDirectory(), "classes");
+
+ protected File getClassDirectory()
+ {
+ if ( classDirectory == null )
+ {
+ classDirectory = new File( mojo.getMavenProject().getBuild().getDirectory(), "classes" );
}
return classDirectory;
}
-
- protected Set getIncludes() {
- if (includes.isEmpty()) {
- includes.add("**/*.class");
+
+ protected Set getIncludes()
+ {
+ if ( includes.isEmpty() )
+ {
+ includes.add( "**/*.class" );
}
return includes;
}
-
- protected File getTimestampDirectory() {
- if (timestampDirectory == null) {
+
+ protected File getTimestampDirectory()
+ {
+ if ( timestampDirectory == null )
+ {
timestampDirectory = getJniDirectory();
}
return timestampDirectory;
}
- protected File getTimestampFile() {
- if (timestampFile == null) {
- timestampFile = new File(name);
+ protected File getTimestampFile()
+ {
+ if ( timestampFile == null )
+ {
+ timestampFile = new File( name );
}
- return timestampFile;
+ return timestampFile;
}
-
- public void execute() throws MojoExecutionException, MojoFailureException {
+
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
getClassDirectory().mkdirs();
-
- try {
- SourceInclusionScanner scanner = new StaleSourceScanner(staleMillis, getIncludes(), excludes);
- if (getTimestampDirectory().exists()) {
- scanner.addSourceMapping(new SingleTargetSourceMapping( ".class", getTimestampFile().getPath() ));
- } else {
- scanner.addSourceMapping(new SuffixMapping( ".class", ".dummy" ));
+
+ try
+ {
+ SourceInclusionScanner scanner = new StaleSourceScanner( staleMillis, getIncludes(), excludes );
+ if ( getTimestampDirectory().exists() )
+ {
+ scanner.addSourceMapping( new SingleTargetSourceMapping( ".class", getTimestampFile().getPath() ) );
}
+ else
+ {
+ scanner.addSourceMapping( new SuffixMapping( ".class", ".dummy" ) );
+ }
+
+ Set classes = scanner.getIncludedSources( getClassDirectory(), getTimestampDirectory() );
- Set classes = scanner.getIncludedSources(getClassDirectory(), getTimestampDirectory());
-
- if (!classes.isEmpty()) {
+ if ( !classes.isEmpty() )
+ {
Set files = new HashSet();
- for (Iterator i=classes.iterator(); i.hasNext(); ) {
- String file = ((File)i.next()).getPath();
- JavaClass clazz = NarUtil.getBcelClass(file);
+ for ( Iterator i = classes.iterator(); i.hasNext(); )
+ {
+ String file = ( (File) i.next() ).getPath();
+ JavaClass clazz = NarUtil.getBcelClass( file );
Method[] method = clazz.getMethods();
- for (int j=0; j<method.length; j++) {
- if (method[j].isNative()) files.add(clazz.getClassName());
+ for ( int j = 0; j < method.length; j++ )
+ {
+ if ( method[j].isNative() )
+ files.add( clazz.getClassName() );
}
}
-
- if (!files.isEmpty()) {
+
+ if ( !files.isEmpty() )
+ {
getJniDirectory().mkdirs();
getTimestampDirectory().mkdirs();
- mojo.getLog().info( "Running "+name+" compiler on "+files.size()+" classes...");
- int result = NarUtil.runCommand(name, generateArgs(files), null, mojo.getLog());
- if (result != 0) {
- throw new MojoFailureException(name+" failed with exit code "+result+" 0x"+Integer.toHexString(result));
+ mojo.getLog().info( "Running " + name + " compiler on " + files.size() + " classes..." );
+ int result = NarUtil.runCommand( name, generateArgs( files ), null, mojo.getLog() );
+ if ( result != 0 )
+ {
+ throw new MojoFailureException( name + " failed with exit code " + result + " 0x"
+ + Integer.toHexString( result ) );
}
- FileUtils.fileWrite(getTimestampDirectory()+"/"+getTimestampFile(), "");
+ FileUtils.fileWrite( getTimestampDirectory() + "/" + getTimestampFile(), "" );
}
}
- } catch (InclusionScanException e) {
+ }
+ catch ( InclusionScanException e )
+ {
throw new MojoExecutionException( "JAVAH: Class scanning failed", e );
- } catch (IOException e) {
+ }
+ catch ( IOException e )
+ {
throw new MojoExecutionException( "JAVAH: IO Exception", e );
- } catch (ClassFormatException e) {
- throw new MojoExecutionException( "JAVAH: Class could not be inspected", e);
+ }
+ catch ( ClassFormatException e )
+ {
+ throw new MojoExecutionException( "JAVAH: Class could not be inspected", e );
}
}
- private String[] generateArgs(Set/*<String>*/ classes) throws MojoExecutionException {
-
+ private String[] generateArgs( Set/* <String> */classes )
+ throws MojoExecutionException
+ {
+
List args = new ArrayList();
-
- if (!bootClassPaths.isEmpty()) {
- args.add("-bootclasspath");
- args.add(StringUtils.join(bootClassPaths.iterator(), File.pathSeparator));
+
+ if ( !bootClassPaths.isEmpty() )
+ {
+ args.add( "-bootclasspath" );
+ args.add( StringUtils.join( bootClassPaths.iterator(), File.pathSeparator ) );
}
-
- args.add("-classpath");
- args.add(StringUtils.join(getClassPaths().iterator(), File.pathSeparator));
-
- args.add("-d");
- args.add(getJniDirectory().getPath());
-
- if (mojo.getLog().isDebugEnabled()) {
- args.add("-verbose");
+
+ args.add( "-classpath" );
+ args.add( StringUtils.join( getClassPaths().iterator(), File.pathSeparator ) );
+
+ args.add( "-d" );
+ args.add( getJniDirectory().getPath() );
+
+ if ( mojo.getLog().isDebugEnabled() )
+ {
+ args.add( "-verbose" );
}
-
- if (classes != null) {
- for (Iterator i = classes.iterator(); i.hasNext(); ) {
- args.add((String)i.next());
+
+ if ( classes != null )
+ {
+ for ( Iterator i = classes.iterator(); i.hasNext(); )
+ {
+ args.add( (String) i.next() );
}
}
-
- return (String[])args.toArray(new String[args.size()]);
- }
-}
+ return (String[]) args.toArray( new String[args.size()] );
+ }
+}