Gradle中的WildFly Swarm + War +本地Jar依赖项 - NullPointerException

时间:2016-11-13 14:08:22

标签: java gradle war wildfly-swarm

我正在尝试使用WildFly Swarm构建一个Web应用程序服务器,并且应用程序必须能够在其中运行另一个Java程序(我不想将其作为外部进程运行)。我试图将外部程序作为.jar依赖项包含在我的Web应用程序中,但是,wildfly-swarm-package任务总是失败,并带有以下内容:

:clean
:compileJava
:processResources UP-TO-DATE
:classes
:war
:wildfly-swarm-package FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':wildfly-swarm-package'.
> java.lang.NullPointerException (no error message)

这是我的gradle.build文件:

buildscript {
  version = System.getProperty('swarmVersion') ?: '2016.10.0'

  repositories {
    mavenLocal()
    mavenCentral()
  }

  dependencies {
    classpath "io.spring.gradle:dependency-management-plugin:0.5.6.RELEASE"
    classpath "org.wildfly.swarm:wildfly-swarm-plugin:$version"
  }
}

apply plugin: "io.spring.dependency-management"
apply plugin: 'wildfly-swarm'
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'war'

//mainClassName = 'org.siret.prank.webapp.rest.Main'

swarm {
  properties {
    swarm.http.port = 8181
  }
}

repositories {
  mavenLocal()
  mavenCentral()
  maven {
    url 'https://maven.repository.redhat.com/nexus/content/repositories/releases/'
  }
  maven {
    url 'https://maven.repository.redhat.com/nexus/content/repositories/thirdparty-releases/'
  }
  flatDir {
       dirs 'libs'
   }
}

dependencyManagement {
  imports {
    mavenBom "org.wildfly.swarm:bom-all:$version"
  }
}

dependencies {
  compile group: 'org.biojava', name: 'biojava-core', version: '4.2.4'
  compile group: 'org.biojava', name: 'biojava-structure', version: '4.2.4'
  compile "org.wildfly.swarm:jaxrs"
  compile group: 'org.wildfly.swarm', name: 'undertow', version: '2016.10.0'
  compile 'org.codehaus.groovy:groovy-all:2.4.7'
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile fileTree(dir: 'libs/lib', include: ['*.jar'])
}

task debugJar(dependsOn:"wildfly-swarm-package") << {
  javaexec {
    main="-jar";
    args=[
            "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006",
            "build/libs/prank-webapp-swarm.jar"
    ]
  }
}

task runJar(dependsOn:"wildfly-swarm-package") << {
  javaexec {
    main="-jar";
    args=[
            "build/libs/prank-webapp-swarm.jar"
    ]
  }
}

War插件工作正常,我可以在档案中找到WEB-INF / lib目录中的jar。

作为一项实验,我尝试清空libs文件夹,错误仍然存​​在。

谢谢, 卢卡斯

1 个答案:

答案 0 :(得分:0)

我迁移到Maven,发现importing jar to local maven repository是问题的答案。

现在,Maven和Gradle都在工作。