将JOGL包装成脂肪JAR

时间:2018-10-04 13:10:26

标签: java opengl gradle jar processing

我在Java 8应用程序中使用了Processing,它在IntelliJ上运行良好。在Gradle导出所有平台的胖罐(下面的代码)包装依赖项之后,就会发生此问题:

jar {
    baseName = applicationName
    version = actualVersion
    manifest { attributes 'Main-Class': mainClassName }
    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

每当我尝试打开扩展PApplet的窗口时,都会引发此异常:

  

com.jogamp.opengl.GLException:配置文件[GL4bc,GL4,GL3bc,GL3,GLES3,GL2,GLES2]在设备WindowsGraphicsDevice [type .windows,connection decon,unitID 0,handle 0x0,owner false,NullToolkitLock中不可用[obj 0x76dc78af]   在com.jogamp.opengl.GLProfile.get(GLProfile.java:1039)   在com.jogamp.opengl.GLProfile.get(GLProfile.java:1050)   在com.jogamp.opengl.GLProfile.getMaxProgrammable(GLProfile.java:826)   在processing.opengl.PSurfaceJOGL.initGL(PSurfaceJOGL.java:203)   在processing.opengl.PSurfaceJOGL.initFrame(PSurfaceJOGL.java:136)   在processing.core.PApplet.initSurface(PApplet.java:10877)   在processing.core.PApplet.runSketch(PApplet.java:10764)   在processing.core.PApplet.main(PApplet.java:10501)   在processing.core.PApplet.main(PApplet.java:10483)

这是我的依赖项

dependencies {
    compile 'org.processing:core:3.3.5'
    compile 'org.jogamp.jogl:jogl-all:2.3.2'
    compile 'org.jogamp.gluegen:gluegen-rt:2.3.2'
    testCompile 'org.json:json:20180130'
    compile files('libs/proscene.jar', 'libs/controlP5.jar')

    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-macosx-universal"
    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-windows-amd64"
    runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-windows-i586"

    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-macosx-universal"
    // runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-solaris-i586"
    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-windows-amd64"
    runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-windows-i586"

    testCompile('org.junit.jupiter:junit-jupiter-api:5.1.0',
            'org.junit.jupiter:junit-jupiter-params:5.1.0')
    testRuntime('org.junit.jupiter:junit-jupiter-engine:5.1.0',
            'org.junit.platform:junit-platform-launcher:1.1.0')
}

在处理和JOGL论坛周围进行挖掘并没有太大帮助。我该怎么办?

P / S:一件奇怪的事情是,通过Eclipse导出胖子罐将以某种方式使罐子中的jogl可运行。

1 个答案:

答案 0 :(得分:0)

好像我找到了解决方案。我使用了shadow,它有助于将所有依赖项捆绑到可执行文件的胖子中。现在JOGL可以正常工作。