diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d913617 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..30a70b3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + org.apache.maven.archetypes + maven-archetype-nar-jni + 1.0-SNAPSHOT + Archetype - maven-archetype-nar-jni + http://maven.apache.org + + + install + + diff --git a/src/main/resources/META-INF/maven/archetype.xml b/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 0000000..cb8012b --- /dev/null +++ b/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,12 @@ + + maven-archetype-nar-jni + + src/main/c/NativeApp.c + + + src/main/java/NativeApp.java + + + src/test/java/NativeAppTest.java + + diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000..35a8343 --- /dev/null +++ b/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + ${groupId} + ${artifactId} + nar + ${version} + + Maven NAR JNI Project + + + true + + + + integration-test + + + maven-nar-plugin + true + + + + jni + ${groupId} + + + + + + + + + + junit + junit + 3.8.1 + + + diff --git a/src/main/resources/archetype-resources/src/main/c/NativeApp.c b/src/main/resources/archetype-resources/src/main/c/NativeApp.c new file mode 100644 index 0000000..85843f0 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/c/NativeApp.c @@ -0,0 +1,20 @@ +#set($foo = "hello?") +#set($fr = "._") +#set($a = $fr.charAt(0)) +#set($b = $fr.charAt(1)) + +\#include +\#include "${groupId.replace($a, $b)}_NativeApp.h" + +JNIEXPORT jstring JNICALL Java_${groupId.replace($a, $b)}_NativeApp_sayHello( JNIEnv *env, jobject obj ) { + jstring value; /* the return value */ + + char buf[40]; /* working buffer (really only need 20 ) */ + + sprintf ( buf, "%s", "Hello NAR World!" ); + + value = (*env)->NewStringUTF( env, buf ); + + return value; +} + diff --git a/src/main/resources/archetype-resources/src/main/java/NativeApp.java b/src/main/resources/archetype-resources/src/main/java/NativeApp.java new file mode 100644 index 0000000..93301a6 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/java/NativeApp.java @@ -0,0 +1,17 @@ +package ${groupId}; + +public class NativeApp +{ + static + { + NarSystem.loadLibrary(); + } + + public final native String sayHello(); + + public static void main( String[] args ) + { + NativeApp app = new NativeApp(); + System.out.println( app.sayHello() ); + } +} diff --git a/src/main/resources/archetype-resources/src/test/java/NativeAppTest.java b/src/main/resources/archetype-resources/src/test/java/NativeAppTest.java new file mode 100644 index 0000000..25bfa1a --- /dev/null +++ b/src/main/resources/archetype-resources/src/test/java/NativeAppTest.java @@ -0,0 +1,16 @@ +package ${groupId}; + +import ${groupId}.NativeApp; + +import junit.framework.Assert; +import junit.framework.TestCase; + +public class NativeAppTest extends TestCase +{ + public final void testNativeApp() + throws Exception + { + NativeApp app = new NativeApp(); + Assert.assertEquals( "Hello NAR World!", app.sayHello() ); + } +}