简体   繁体   English

如何将NetBeans ant构建移植到构建服务器(Atlassian Bamboo)

[英]How to port NetBeans ant build into build server (Atlassian Bamboo)

I'd like to have my NetBeans project build in bamboo. 我想用竹子构建我的NetBeans项目。 Most of it seems to be working but I'm not able to launch my project like I can when I build in NetBeans. 它中的大多数似乎都在工作,但是我无法像在NetBeans中构建时那样启动项目。

When I build in netbeans it (by the default ant build) sticks my dependent libraries into a directory called dist/lib/commons-math3-3.6.1.jar and my jar is created in: dist/MyJar.jar. 当我在netbeans中进行构建时(通过默认的ant构建),它将我的依赖库粘贴到名为dist / lib / commons-math3-3.6.1.jar的目录中,并且在以下位置创建我的jar:dist / MyJar.jar。 I can run my jar by typing 我可以输入以下内容来运行我的jar

java -jar MyJar.jar

and it will find my dependent libraries. 它将找到我的依赖库。 However when I build in bamboo there is one thing different that I noticed which is my libraries did not get copied to dist/lib/. 但是,当我用Bamboo进行构建时,我发现有一点不同,那就是我的库没有被复制到dist / lib /。 but since they are in the root of my project its not a problem i just go ahead and recopy them from my /libs/ to /dist/lib/ and then i try the "java -jar MyJar.jar" command but i get this error: 但由于它们位于我项目的根目录中,所以这不是问题,我只是将它们从我的/ libs /复制到/ dist / lib /,然后尝试“ java -jar MyJar.jar”命令,但是我得到了错误:

james@build.mycompany.com:~dist/$ java -jar MyJar.jar 
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/math3/stat/descriptive/moment/StandardDeviation
    at readnthvalue.App.<clinit>(App.java:26)
    at readnthvalue.MainFrame.<init>(MainFrame.java:31)
    at readnthvalue.MainFrame.lambda$main$0(MainFrame.java:365)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.stat.descriptive.moment.StandardDeviation
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 17 more

Any thoughts or advise from someone with knowledge in ant and atlassian bamboo is greatly appreciated. 任何对蚂蚁和Atlassian竹有知识的人的任何想法或建议都将不胜感激。

I should mention that the md5sum is different from the working jar and the one built with bamboo. 我应该提到md5sum与工作罐和用竹子制成的罐不同。

I use the command: ant clean jar to build from command line 我使用以下命令:ant clean jar从命令行构建

UPDATE 8-04-2017 更新8-04-2017

I noticed that on bamboo I get this: 我注意到在竹子上我得到了:

build   04-Aug-2017 14:02:51    -do-jar-jar:
build   04-Aug-2017 14:02:51    [j2seproject1:jar] Building jar: /home/filtec/bamboo-home/xml-data/build-dir/AUR-ATP-JOB1/dist/auratec-helper.jar
build   04-Aug-2017 14:02:51         [echo] To run this application from the command line without Ant, try:
build   04-Aug-2017 14:02:51         [echo] /home/filtec/jdk1.8.0_65/jre/bin/java -cp /home/filtec/bamboo-home/xml-data/build-dir/AUR-ATP-JOB1/libs/jfreechart-1.0.19.jar:/home/filtec/bamboo-home/xml-data/build-dir/AUR-ATP-JOB1/libs/jcommon-1.0.23.jar:/home/filtec/bamboo-home/xml-data/build-dir/AUR-ATP-JOB1/libs/commons-math3-3.6.1.jar:/home/filtec/bamboo-home/xml-data/build-dir/AUR-ATP-JOB1/libs/jSerialComm-1.3.11.jar:/home/filtec/bamboo-home/xml-data/build-dir/AUR-ATP-JOB1/dist/auratec-helper.jar filtec.auratec.MainFrame

but in NetBeans I get this output: 但是在NetBeans中,我得到以下输出:

Building jar: /home/james/NetBeansProjects/auratec-helper/dist/auratec-helper.jar
To run this application from the command line without Ant, try:
java -jar "/home/james/NetBeansProjects/auratec-helper/dist/auratec-helper.jar"

So I guess my new updated question is why is the build on the bamboo server different in behavior from on my workstation. 所以我想我的新更新问题是,为什么在Bamboo服务器上构建的行为与在工作站上有所不同。 What are the dependent jars not copied and why am i able to use the -jar option to run the files where as on the build server i need to use vanilla java to run when building from an ant script on the bamboo server. 什么是未复制的依赖jar,为什么我可以使用-jar选项来运行文件,如在构建服务器上从竹服务器上的ant脚本进行构建时,我需要使用vanilla java来运行。

This was a pain to figure out. 很难弄清楚。 Basically the copylibstask.jar needed to be available to ant on bamboo but because NetBeans is not installed on the build server we need to reference it manually. 基本上,copylibstask.jar需要可用于在竹子上的ant,但是由于NetBeans未安装在构建服务器上,因此我们需要手动引用它。 I've placed a copy into /libs/org-netbeans-modules-java-j2seproject-copylibstask.jar and am referencing it in the project.properties file. 我已将副本放入/libs/org-netbeans-modules-java-j2seproject-copylibstask.jar,并在project.properties文件中引用它。

# this is needed for the ant build
libs.CopyLibs.classpath=libs/org-netbeans-modules-java-j2seproject-copylibstask.jar

The libraries are now copying and the jar is executable again. 库现在正在复制,jar可以再次执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM