-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1853f3b
Showing
7 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.apache.maven.archetypes</groupId> | ||
<artifactId>maven-archetype-nar-jni</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>Archetype - maven-archetype-nar-jni</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<build> | ||
<defaultGoal>install</defaultGoal> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<archetype> | ||
<id>maven-archetype-nar-jni</id> | ||
<resources> | ||
<resource>src/main/c/NativeApp.c</resource> | ||
</resources> | ||
<sources> | ||
<source>src/main/java/NativeApp.java</source> | ||
</sources> | ||
<testSources> | ||
<source>src/test/java/NativeAppTest.java</source> | ||
</testSources> | ||
</archetype> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>${groupId}</groupId> | ||
<artifactId>${artifactId}</artifactId> | ||
<packaging>nar</packaging> | ||
<version>${version}</version> | ||
|
||
<name>Maven NAR JNI Project</name> | ||
|
||
<properties> | ||
<skipTests>true</skipTests> | ||
</properties> | ||
|
||
<build> | ||
<defaultGoal>integration-test</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-nar-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<libraries> | ||
<library> | ||
<type>jni</type> | ||
<narSystemPackage>${groupId}</narSystemPackage> | ||
</library> | ||
</libraries> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
20 changes: 20 additions & 0 deletions
20
src/main/resources/archetype-resources/src/main/c/NativeApp.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#set($foo = "hello?") | ||
#set($fr = "._") | ||
#set($a = $fr.charAt(0)) | ||
#set($b = $fr.charAt(1)) | ||
|
||
\#include <stdio.h> | ||
\#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; | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
src/main/resources/archetype-resources/src/main/java/NativeApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() ); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/resources/archetype-resources/src/test/java/NativeAppTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() ); | ||
} | ||
} |