On 6 Jun 07, at 2:50 AM 6 Jun 07, Arne Styve wrote:
Hi Jason,
Thanks for your input. I'll give this a try. However, how do you
then use the JAR containing all the DLLs and .so's ? As far as I've
understood, you cannot access a DLL that is inside a JAR, and hence
you have to extract the DLLs from the JAR in order to use the DLL.
Is this correct ?
There is an artifact handler that unpacks them to be used from the
local repository. Mark has the full details as he's the one who
implemented the solution and is working great at SLAC.
Regards Arne
________________________________
On Tue, June 5, 2007 10:07 am, Arne Styve wrote:
I have a question related to using DLLs with Maven. We colaborate
with a
company that develops parts of our system. They deliver their
component as
a set of DLLs. I've used JNI to create a Java interface to these
DLL, so
that I can use Java to develop the software that will use the DLLs.
How can I set up a Maven2 project that takes these DLLs and deploy
them
correctly to our company repository, so that I in my project,
where I am
going to use the DLLs, can add dependencies to the DLLs the usual
Maven2
way ? I.e. this project will not have any sourcefiles, only the 4
DLLs.
We faced the same problem.
Originally we tried to publish the DLL artifact into the repository
directly, but this caused problems for us, as our JNI native code
had to
run on Windows, Linux and Solaris, and maintaining the proper naming
conventions and suffixes was a pain.
We eventually opted to wrap the JNI DLLs / .so files inside a jar, and
publish the jar in the repository, including a classifier to show
both the
platform (windows / linux / solaris) and architecture (x86, amd64,
etc).
From that point on we only needed to worry about the name of the jar,
which was consistent across platforms.
When you have multiple DLLs, putting them in a jar reduces them
down from
many artifacts to one artifact, which is easier to deal with.
This is the pom we use, it should give some clues. The DLLs are
built by
ant using the antrun plugin, and maven worries about the packaging and
deployment:
<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>
<parent>
<artifactId>alchemy-ii-native</artifactId>
<groupId>alchemy</groupId>
<version>4.0.30-SNAPSHOT</version>
</parent>
<artifactId>alchemy-cdo</artifactId>
<packaging>jar</packaging>
<name>Alchemy Native CDO</name>
<description>Placeholder for the CDO stuff from London</description>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
<sourceDirectory>src/main/java</sourceDirectory>
<!-- <testSourceDirectory>src</testSourceDirectory>-->
<resources>
<resource>
<directory>target/build</directory>
<includes>
<include>*.dll</include>
</includes>
</resource>
<resource>
<directory>target/build</directory>
<includes>
<include>*.dylib</include>
</includes>
</resource>
<resource>
<directory>target/build</directory>
<includes>
<include>*.so</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>alchemy-cdo-version.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<!-- Generate JNI header files based on a list of class
name on
the classpath -->
<!-- The generated include directory is automatically
added to
include path at compile phase -->
<!-- Ensure to have appropriate denpendency jar file(s) in
your
pom -->
<executions>
<execution>
<id>javah</id>
<phase>generate-sources</phase>
<configuration>
<classNames>
<className>alchemy.cdo.measure.CDOTranche</className>
</classNames>
<!--
| Note:
| 1. Without classNames, javah mojo will search
for all
JNI classes
| in your dependency list.
-->
</configuration>
<goals>
<goal>javah</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- trigger the ant build -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>2antrun</id>
<phase>process-sources</phase><!-- needs to run BEFORE
resources -->
<configuration>
<tasks>
<ant target="compile-cc-${os-platform}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>cpptasks</artifactId>
<version>1.0b3</version>
</dependency>
</dependencies>
</plugin>
<!-- jar plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${os-platform}-${os-arch}</classifier>
</configuration>
</execution>
</executions>
</plugin>
<!-- manually define the artifacts ant produces for
deployment -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${artifactId}-$
{version}-${os-platform}-${os-arch}.jar</file>
<type>jar</type>
<classifier>${os-platform}-${os-arch}</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<!-- site plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<siteDirectory>${basedir}/site/</siteDirectory>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- CDO Client jar -->
<dependency>
<groupId>alchemy</groupId>
<artifactId>alchemy-cdo-client</artifactId>
<version>${pom.version}</version>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jxr-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-clover-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<targetjdk>1.5</targetjdk>
<rulesets>
<ruleset>/rulesets/basic.xml</ruleset>
<ruleset>/rulesets/controversial.xml</ruleset>
</rulesets>
<format>xml</format>
<linkXref>true</linkXref>
<sourceEncoding>utf-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>changes-maven-plugin</artifactId>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>changelog-maven-plugin</artifactId>
</plugin>
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>
Regards,
Graham
--
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Thanks,
Jason
----------------------------------------------------------
Jason van Zyl
Founder and PMC Chair, Apache Maven
jason at sonatype dot com
----------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]