使用maven构建OS特定的Jogl Jar:每个os-arch一个程序集?

时间:2014-08-22 16:30:31

标签: maven jogl

很久以前,有this post。我不确切知道Jogamp何时开始将本机库作为jar存档发布,但是这个新组织让我觉得打包特定于os的jar会更容易,但我现在还没有足够的知识。< / p>

Jogamp已经放了一个pom.xml来下载所有库,但我所取得的就是重新组合最终输出jar中的所有jar。

我已经看到可以在pom.xml中使用几个自定义程序集:我如何定义这些程序集的单个版本作为示例(我的意思是,例如,目标是linux-64)? / p>

1 个答案:

答案 0 :(得分:2)

最后,我设法定义了几个程序集,并使用maven构建输出。 我使用这种方法here

创建了一个小型JOGL项目

这是Linux64的程序集,例如(位于src / main / assembly文件夹中):

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  <id>linux-amd64</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <dependencySets>
    <dependencySet>
      <useProjectArtifact>false</useProjectArtifact>
      <unpack>false</unpack>
      <includes>
        <include>org.jogamp.jogl:jogl-all:jar:2.2.0</include>
        <include>org.jogamp.jogl:jogl-all:jar:natives-linux-amd64:2.2.0</include>
        <include>org.jogamp.gluegen:gluegen-rt:jar:2.2.0</include>
        <include>org.jogamp.gluegen:gluegen-rt:jar:natives-linux-amd64:2.2.0</include>
      </includes>
    </dependencySet>
  </dependencySets>
</assembly>

这是我的pom.xml:

<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.loloof64.java</groupId>
    <artifactId>Simple3DCube</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Simple3DCube</name>
    <description>A simple 3D Cube with JOGL</description>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jogamp.gluegen</groupId>
            <artifactId>gluegen-rt-main</artifactId>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.jogamp.jogl</groupId>
            <artifactId>jogl-all-main</artifactId>
            <version>2.2.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.loloof64.java.simple_3d_cube.Launcher</mainClass>
                            <packageName>com.loloof64.java.simple_3d_cube</packageName>
                        </manifest>
                    </archive>

                    <descriptors>
                        <descriptor>src/main/assembly/windows32-assembly.xml</descriptor>
                        <descriptor>src/main/assembly/windows64-assembly.xml</descriptor>
                        <descriptor>src/main/assembly/linux32-assembly.xml</descriptor>
                        <descriptor>src/main/assembly/linux64-assembly.xml</descriptor>
                        <descriptor>src/main/assembly/solaris32-assembly.xml</descriptor>
                        <descriptor>src/main/assembly/solaris64-assembly.xml</descriptor>
                        <descriptor>src/main/assembly/macosx-universal-assembly.xml</descriptor>
                    </descriptors>


                </configuration>
            </plugin>
        </plugins>
    </build>
</project>