1

Mavenを使用して管理およびビルドしようとしているサンプル/おもちゃのJNIプロジェクトがあります。サブプロジェクトは次のとおりです。

  • MathFuncs:純粋なネイティブコード(C ++)
  • JMathFuncsNative:MathFuncsのクラスをJNIでラップするネイティブコード
  • JMathFuncs:JMathFuncsNativeをロードし、そのメソッドを呼び出すJavaスタブコード
  • JHello:JMathFuncsを使用するJavaアプリケーションコード

各プロジェクトは、そのすぐ上のアーティファクトにのみ直接依存し、その上のすべてに推移的な依存関係を持つ必要があります。

mvn dependency:tree各プロジェクトで実行する場合:

  • MathFuncsは(予想どおり)何にも依存していません。
  • JMathFuncsNativeはMathFuncsに依存します(予想どおり):実行時のdll、コンパイル時のlibおよびinczip。
  • JMathFuncsはJMathFuncsNative(ランタイムスコープ)に依存しますが、推移的なMathFuncs依存関係を取得しません。
  • JHelloはすべてに依存しています(予想どおり)。

mvn dependency:tree親ディレクトリから実行する場合:

  • MathFuncsは(予想どおり)何にも依存していません。
  • JMathFuncsNativeはMathFuncsに依存します(予想どおり):実行時のdll、コンパイル時のlibおよびinczip。
  • JMathFuncsはJMathFuncsNative(ランタイムスコープ)に依存しますが、推移的なMathFuncs依存関係を取得しません。
  • JHelloはJMathFuncs(コンパイルスコープ)に依存します。これはJMathFuncsNative(ランタイムスコープ)に依存しますが、MathFuncs依存関係はありません。

誰かがこれらの依存関係を解決するのを手伝ってもらえますか?

編集:
ここにPOMがあります。上記のプロジェクト名を編集して、以下のPOMに表示されるものと一致させました。

親POM:

<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>com.mycompany.samples</groupId>
<artifactId>maven-test-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
    <module>MathFuncs</module>
    <module>JMathFuncs</module>
    <module>JMathFuncsNative</module>
    <module>JHello</module>
</modules>
</project>

MathFuncs POM:

<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>com.mycompany.samples</groupId>
<artifactId>MathFuncs</artifactId>
<packaging>dll</packaging>
<version>1.0-SNAPSHOT</version>

<parent>
    <groupId>com.mycompany.samples</groupId>
    <artifactId>maven-test-sample</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <extensions>true</extensions>
            <version>1.0-alpha-7</version>

            <configuration>
                <compilerProvider>msvc</compilerProvider>
                <compilerStartOptions>
                    <compilerStartOption> /EHsc /W4</compilerStartOption>
                    <compilerStartOption>-D_WIN32_WINNT=0x0500</compilerStartOption>
                </compilerStartOptions>

                <sources>
                    <source>
                        <directory>src/main/native</directory>
                        <includes>
                            <include>**/*.cpp</include>
                            <include>**/*.c</include>
                        </includes>
                    </source>
                    <source>
                        <directory>src/main/native/include</directory>
                        <deployable>true</deployable>
                    </source>
                </sources>

                <linkerProvider>msvc</linkerProvider>
                <linkerSecondaryOutputExtensions>lib</linkerSecondaryOutputExtensions>
                <linkerStartOptions>
                    <linkerStartOption> /INCREMENTAL:NO /DLL </linkerStartOption>
                </linkerStartOptions>
            </configuration>

        </plugin>
    </plugins>
</build>

JMathFuncsNative POM:

<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>com.mycompany.samples</groupId>
<artifactId>JMathFuncsNative</artifactId>
<packaging>dll</packaging>
<version>1.0-SNAPSHOT</version>

<parent>
    <groupId>com.mycompany.samples</groupId>
    <artifactId>maven-test-sample</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<dependencies>
    <dependency>
        <groupId>com.mycompany.samples</groupId>
        <artifactId>MathFuncs</artifactId>
        <version>1.0-SNAPSHOT</version>
        <scope>runtime</scope>
        <type>dll</type>
    </dependency>
    <dependency>
        <groupId>com.mycompany.samples</groupId>
        <artifactId>MathFuncs</artifactId>
        <version>1.0-SNAPSHOT</version>
        <scope>compile</scope>
        <type>lib</type>
    </dependency>
    <dependency>
        <groupId>com.mycompany.samples</groupId>
        <artifactId>MathFuncs</artifactId>
        <version>1.0-SNAPSHOT</version>
        <scope>compile</scope>
        <type>inczip</type>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <extensions>true</extensions>
            <version>1.0-alpha-7</version>

            <configuration>
                <compilerProvider>msvc</compilerProvider>
                <compilerStartOptions>
                    <compilerStartOption> /EHsc /W4</compilerStartOption>
                    <compilerStartOption>-D_WIN32_WINNT=0x0500</compilerStartOption>
                </compilerStartOptions>

                <sources>
                    <source>
                        <directory>src/main/native</directory>
                        <includes>
                            <include>**/*.cpp</include>
                            <include>**/*.c</include>
                        </includes>
                    </source>
                    <source>
                        <directory>src/main/native/include</directory>
                        <deployable>true</deployable>
                    </source>
                    <source>
                        <directory>${java.home}\..\include</directory>
                    </source>
                    <source>
                        <directory>${java.home}\..\include\win32</directory>
                    </source>
                </sources>

                <linkerProvider>msvc</linkerProvider>
                <linkerSecondaryOutputExtensions>lib</linkerSecondaryOutputExtensions>
                <linkerStartOptions>
                    <linkerStartOption> /INCREMENTAL:NO /DLL </linkerStartOption>
                </linkerStartOptions>
            </configuration>

        </plugin>
    </plugins>
</build>

JMathFuncs POM:

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>com.mycompany.samples</groupId>
    <artifactId>maven-test-sample</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.mycompany.samples</groupId>
<artifactId>JMathFuncs</artifactId>
<version>1.0-SNAPSHOT</version>
<name>JMathFuncs</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>com.mycompany.samples</groupId>
        <artifactId>JMathFuncsNative</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>dll</type>
        <scope>runtime</scope>
    </dependency>
</dependencies>

</project>

JHello POM:

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.mycompany.samples</groupId>
    <artifactId>maven-test-sample</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<groupId>com.mycompany.samples</groupId>
<artifactId>JHello</artifactId>
<version>1.0-SNAPSHOT</version>
<name>JHello</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>com.mycompany.samples</groupId>
        <artifactId>JMathFuncs</artifactId>
        <version>1.0-SNAPSHOT</version>
        <scope>compile</scope>
   </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.5.1</version>
            <executions>
                <execution>
                    <id>copy-libs</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}</outputDirectory>
                        <stripVersion>true</stripVersion>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>

そして、mvn dependency:tree親ディレクトリからの出力:

[INFO] Scanning for projects...  
[INFO] ------------------------------------------------------------------------  
[INFO] Reactor Build Order:  
[INFO]   
[INFO] maven-test-sample  
[INFO] MathFuncs  
[INFO] JMathFuncsNative  
[INFO] JMathFuncs  
[INFO] JHello  
[INFO]                                                                           
[INFO] ------------------------------------------------------------------------  
[INFO] Building maven-test-sample 1.0-SNAPSHOT  
[INFO] ------------------------------------------------------------------------  
[INFO]   
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ maven-test-sample ---  
[INFO] com.mycompany.samples:maven-test-sample:pom:1.0-SNAPSHOT  
[INFO]                                                                           
[INFO] ------------------------------------------------------------------------  
[INFO] Building MathFuncs 1.0-SNAPSHOT  
[INFO] ------------------------------------------------------------------------  
[INFO]   
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ MathFuncs ---  
[INFO] com.mycompany.samples:MathFuncs:dll:1.0-SNAPSHOT  
[INFO]                                                                           
[INFO] ------------------------------------------------------------------------  
[INFO] Building JMathFuncsNative 1.0-SNAPSHOT  
[INFO] ------------------------------------------------------------------------  
[INFO]   
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ JMathFuncsNative ---  
[INFO] com.mycompany.samples:JMathFuncsNative:dll:1.0-SNAPSHOT  
[INFO] +- com.mycompany.samples:MathFuncs:dll:1.0-SNAPSHOT:runtime  
[INFO] +- com.mycompany.samples:MathFuncs:lib:1.0-SNAPSHOT:compile  
[INFO] \- com.mycompany.samples:MathFuncs:inczip:1.0-SNAPSHOT:compile  
[INFO]                                                                           
[INFO] ------------------------------------------------------------------------  
[INFO] Building JMathFuncs 1.0-SNAPSHOT  
[INFO] ------------------------------------------------------------------------  
[INFO]   
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ JMathFuncs ---  
[INFO] com.mycompany.samples:JMathFuncs:jar:1.0-SNAPSHOT  
[INFO] \- com.mycompany.samples:JMathFuncsNative:dll:1.0-SNAPSHOT:runtime  
[INFO]                                                                           
[INFO] ------------------------------------------------------------------------  
[INFO] Building JHello 1.0-SNAPSHOT  
[INFO] ------------------------------------------------------------------------  
[INFO]   
[INFO] --- maven-dependency-plugin:2.5.1:tree (default-cli) @ JHello ---  
[INFO] com.mycompany.samples:JHello:jar:1.0-SNAPSHOT  
[INFO] \- com.mycompany.samples:JMathFuncs:jar:1.0-SNAPSHOT:compile  
[INFO]    \- com.mycompany.samples:JMathFuncsNative:dll:1.0-SNAPSHOT:runtime  
[INFO] ------------------------------------------------------------------------  
[INFO] Reactor Summary:  
[INFO]   
[INFO] maven-test-sample ................................. SUCCESS [0.905s]  
[INFO] MathFuncs ......................................... SUCCESS [0.327s]  
[INFO] JMathFuncsNative .................................. SUCCESS [0.063s]  
[INFO] JMathFuncs ........................................ SUCCESS [0.062s]  
[INFO] JHello ............................................ SUCCESS [0.546s]  
[INFO] ------------------------------------------------------------------------  
[INFO] BUILD SUCCESS  
[INFO] ------------------------------------------------------------------------  
[INFO] Total time: 2.777s  
[INFO] Finished at: Fri Nov 09 14:05:26 EST 2012  
[INFO] Final Memory: 10M/125M  
[INFO] ------------------------------------------------------------------------  
4

0 に答える 0