Refactor win/unix build
authorJakub Skoczen <jakub@indexdata.dk>
Wed, 6 Jun 2012 14:00:26 +0000 (16:00 +0200)
committerJakub Skoczen <jakub@indexdata.dk>
Wed, 6 Jun 2012 14:00:26 +0000 (16:00 +0200)
linux/pom.xml
pom.xml

index bf46f40..ec77628 100644 (file)
             </goals>
             <configuration>
               <tasks>
-                <exec executable="yaz-config" outputproperty="yaz.cflags">
+                <exec executable="${yaz.path}yaz-config" outputproperty="yaz.cflags">
                   <arg value="--cflags" />
                 </exec>
                 <echo message="YAZ CFLAGS: ${yaz.cflags}"/>
-                <exec executable="yaz-config" outputproperty="yaz.libs">
+                <exec executable="${yaz.path}yaz-config" outputproperty="yaz.libs">
                   <arg value="--libs" />
                 </exec>
                 <echo message="YAZ LIBS: ${yaz.libs}"/>
@@ -72,7 +72,8 @@
         <artifactId>native-maven-plugin</artifactId>
         <extensions>true</extensions>       
         <configuration>         
-          <javahOS>linux</javahOS>
+          <javahOS>${javahOS}</javahOS>
+          <jdkIncludePath>${jdkIncludePath}</jdkIncludePath>
           <compilerProvider>generic</compilerProvider>
           <compilerExecutable>g++</compilerExecutable>
           <compilerStartOptions>
diff --git a/pom.xml b/pom.xml
index 80760cd..b5439c9 100644 (file)
--- a/pom.xml
+++ b/pom.xml
             <inherited>false</inherited>
             <configuration>
               <tasks>
-                <exec executable="yaz-config" outputproperty="yaz.prefix">
-                  <arg value="--prefix" />              
-                </exec>
-                <echo message="Using yaz prefix: ${yaz.prefix}"/>
+                <echo message="Using include: ${yaz.include}"/>
                 <mkdir dir="target/generated-sources/java/org/yaz4j/jni"/>
                 <mkdir dir="target/generated-sources/native" />
                 <exec executable="swig">
                   <arg value="-Isrc/main/native" />
-                  <arg value="-I${yaz.prefix}/include"/>
+                  <arg value="${yaz.include}"/>
                   <arg value="-outdir"/>
                   <arg value="${basedir}/target/generated-sources/java/org/yaz4j/jni"/>
                   <arg value="-package"/>
       </activation>
       <properties>
         <platform>win32</platform>
+        <yaz.include>C:\Program Files\YAZ\include</yaz.include>
+        <yaz.path>C:\Program Files\YAZ\</yaz.path>
       </properties>
       <modules>
         <module>win32</module>
       </activation>
       <properties>
         <platform>linux</platform>
+        <!-- must include trailing slash if specified-->
+        <yaz.path></yaz.path>
+        <javahOS>linux</javahOS>
+        <jdkIncludePath>${java.home}/../include</jdkIncludePath>
+      </properties>
+      <modules>
+        <module>linux</module>
+      </modules>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>write-swig-include</id>
+                <phase>initialize</phase>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+                <configuration>
+                  <tasks>
+                    <exec executable="${yaz.path}yaz-config" 
+                      outputproperty="yaz.include">
+                      <arg value="--include" />
+                    </exec>
+                    <echo message="YAZ INCLUDE=${yaz.include}"/>
+                    <mkdir dir="${basedir}/target"/>
+                    <echo file="${basedir}/target/swig.properties"
+                      message="yaz.include=${yaz.include}"/>
+                  </tasks>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin> 
+            <groupId>org.codehaus.mojo</groupId> 
+            <artifactId>properties-maven-plugin</artifactId> 
+            <version>1.0-alpha-1</version> 
+            <executions> 
+              <execution> 
+                <id>read-swig-config</id> 
+                <phase>initialize</phase> 
+                <goals> 
+                  <goal>read-project-properties</goal> 
+                </goals> 
+                <configuration> 
+                  <files> 
+                    <file>${basedir}/target/swig.properties</file> 
+                  </files> 
+                </configuration> 
+              </execution> 
+            </executions> 
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <profile>
+      <!-- osx is both 'unix' and 'mac' -->
+      <id>osx</id>
+      <activation>
+        <os>
+          <family>mac</family>
+        </os>
+      </activation>
+      <properties>
+        <platform>osx</platform>
+        <javahOS>mac</javahOS>
+        <jdkIncludePath>${java.home}/../Headers</jdkIncludePath>
       </properties>
       <modules>
         <module>linux</module>
       </modules>
     </profile>
- </profiles>
+  </profiles>
 </project>