I need to setup a periodic pull & build of a native Netbeans project on a Linux box and I don't want to open the project in the Netbeans GUI to make the generated files up-to-date.
There can be at least one file in a native Netbeans project that should be different on different machines: nbproject/private/private.properties. Here's an example of a web application to build for Glassfish:
deploy.ant.properties.file=/home/admin/.netbeans/8.2/config/GlassFishEE6/Properties/gfv3-155092097.properties
j2ee.platform.is.jsr109=true
j2ee.server.domain=/opt/glassfish-4.1.2/glassfish4/glassfish/domains/domain1
j2ee.server.home=/opt/glassfish-4.1.2/glassfish4/glassfish
j2ee.server.instance=[/opt/glassfish-4.1.2/glassfish4/glassfish:/opt/glassfish-4.1.2/glassfish4/glassfish/domains/domain1]deployer:gfv3ee6wc:localhost:4848
j2ee.server.middleware=/opt/glassfish-4.1.2/glassfish4
user.properties.file=/home/admin/.netbeans/8.2/build.properties
It is not under version control, but without it Ant cannot build projects that use the Glassfish server registered in Netbeans:
[admin#funktest v24testear]$ ant -quiet clean dist
BUILD SUCCESSFUL
Total time: 16 seconds
[admin#funktest v24testear]$ rm -f nbproject/private/private.properties
[admin#funktest v24testear]$ ant -quiet clean dist
BUILD FAILED
/home/admin/Downloads/v24test/v24testear/nbproject/build-impl.xml:156: The libs.CopyLibs.classpath property is not set up.
There's also build-impl.xml that is derived from project.xml and I would like to re-generate it too.
A workaround to this is including and referencing the required lib in your project. For example:
locate the JAR-file org-netbeans-modules-java-j2seproject-copylibstask.jar, which will typically reside in a location like C:\Program Files\NetBeans 8.2\java\ant\extra on a computer with NetBeans.
Copy that JAR into your project, f.x. project/ant/org-netbeans-modules-java-j2seproject-copylibstask.jar.
Open nbproject/project.properties and at the end of it add the line:
libs.CopyLibs.classpath=ant/org-netbeans-modules-java-j2seproject-copylibstask.jar
With the lib in your project and project.properties pointing to its location Ant should be able to build without an actual NetBeans installation.
Related
Is it possible to generate an eclipse workspace using command line so that I can simply switch the workspace in Eclipse and everything is configured? I've already tried many approaches (using mvn eclipse:eclipse which only generates .project files but no workspaces, using the eclipse osgi jar) but I didn't get any of them to work...
mvn eclipse:eclipse is an old an deprecated command. The functionality of this and much more was replaced by Eclipse Oomph. This allows you to just define which plugins and which eclipse version you want and then on the developer computer these things could happen:
install eclipse
install needed plugins
checkout the projects
create files
set specific eclipse settings
build your project
I would suggest not to compile class files on a build server and move them afterwards to a developer PC. I see potential problems in debugging and profiling when the compiler is not exactly the same.
Another approach would be to create the Eclipse installation in a virtual machine (or docker container), deploy the image on the build server, build it there and then distribute the image to the developers.
I'm trying to get my maven project deployed to Jboss AS 7.1 using the jbos tools plugin version 4.3.1.FINAL.
My project setup is
parentPom
common.jar
util.jar
mywebapp.war
When I run mvn clean install form both eclipse and command line the resulting target folder is the same atleast for the mywebapp.war and /mywebapp (folder)
If i copy either the folder or war file from the target folder directly into the servers /standalone/deployments directory. The application starts up without a problem.
However if I go to my server setup in eclipse which is pointing to the same base and do Add/Remove -> select mywebapp -> run
The problem is this doesnt copy all the files over to the server becasue when i run a diff I see a whole load of files missing. Consequently the build fails saying it canot load some annotation, presumably this is because some of the files are missing.
Ideally I wouldn't want to copy the war or folder manually and would love to be able to edit jsp/css/javascript files etc without having to go through this laborious task.
I'm learning Hadoop under VMware now.(win7, 64) Due to some reason, I can't convert a .java file to .jar file under virtual machine, so I tried to create .jar file under Eclipse.
I'm currently using Eclipse MARS(4.5.1). I need to download something about fat jar, but I can't find it online.
My colleague copied his Eclipse software to me. It is already installed, so I copied the whole package. It is Eclipse Kepler. So I am running two Eclipse software on my computer now. will this cause some problem? (I saved projects seperately)
I can do the convert .jar file thing correctly on Eclipse Kepler now. But I still want to use MARS and delete the extra Eclipse.
thank you !
What you're looking for is the "Fat JAR" eclipse plugin.
Fat jar is a jar which contains all the classes used by the project including their referenced dependencies.
The plugin can enable the creation of such a jar.
In your case, however, Eclipse "Mars" & Eclipse "Kepler" include this functionality. The trick is to get to it...
Here's what you do in order to export a Fat JAR:
Right-click on the required Project and select "Export..." --> "Runnable JAR file".
Select the option which extracts libraries and specify the destination JAR file.
Launch configuration is used to execute this JAR with a predefined "Main" class (this is the "Runnable" part...) using "java -jar file.jar".
If you don't plan to - it won't matter.
(Optional) You can also "Save as ANT script" which, well..., generates XML ant script as well.
select project
select Export
Expand the Java node and select JAR file. Click Next
In the JAR File Specification page, select the resources that you want to export in the Select the resources to export field
.
Select the appropriate checkbox to specify whether you want to Export generated class files and resources or Export Java source
or go to http://www.codejava.net/ides/eclipse/how-to-create-jar-file-in-eclipse
I am trying to set up an automatic build system with Jenkins CI for a NetBeans multitiered web application project. This NetBeans project contains an EJB-project (for the business layer of the web application) and a WAR-project (for the web layer of the application). I'm currently stuck on getting Ant to compile the project.
I am using Windows 8 to develop in NetBeans IDE 8.0. Jenkins also runs on Windows 8.
I'm currently looking for someone who understands how to build EJB-projects with Jenkins and Ant.
What I've done so far:
I've set up a NetBeans project (as described above)
I've set up a git repository for the project
I've set up Jenkins CI
I am able to get the project from the git repository with Jenkins CI
I am able to make Jenkins use Ant to clean the project it retrieved
from the git repository
Where I get stuck:
After being succesful to execute the clean command with Ant I want to make the debug command work. For this the project needs to be compiled. Here is where it goes wrong.
I entered the following properties in the Properties field for the Ant Invoke in Jenkins:
libs.CopyLibs.classpath=C:/Program Files/NetBeans 8.0/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar
j2ee.server.home=C:/Program Files/wildfly-8.1.0.Final
In the output of my Jenkins build I see the following command:
[PGB Webapp] $ cmd.exe /C '""C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Ant_AntInstallation\Apache_Ant\bin\ant.bat" "-Dlibs.CopyLibs.classpath=C:/Program Files/NetBeans 8.0/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar" "-Dj2ee.server.home=C:/Program Files/wildfly-8.1.0.Final" clean debug && exit %%ERRORLEVEL%%"'
And this is the last part of my output: (the part that seems most important to me)
init:
-init-cos:
-deps-module-jar:
-deps-ear-jar:
deps-jar:
-pre-pre-compile:
[mkdir] Created dir: C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes
-pre-compile:
-copy-meta-inf:
[copy] Copying 2 files to C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes\META-INF
-do-compile:
[mkdir] Created dir: C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\empty
[mkdir] Created dir: C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\generated-sources\ap-source-output
[javac] Compiling 5 source files to C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes
-post-compile:
compile:
-pre-dist:
library-inclusion-in-manifest:
BUILD FAILED
C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\nbproject\build-impl.xml:204: The following error occurred while executing this line:
C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\nbproject\build-impl.xml:806: Warning: Could not find file C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\${libs.MySQLDriver.classpath} to copy.
Total time: 1 second
Build step 'Start Ant' marked build as failure
Finished: FAILURE
So in this output I see the following warning:
Warning: Could not find file C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\${libs.MySQLDriver.classpath} to copy.
Now, to me this seems to be a rare issue as I can find almost nothing about it on the internet (or am I using the wrong search term?) I've searched on Google, here on SO, and DuckDuckGo, and I could only find the following (pretty useless) clues to my problem: (pretty useless because the warning I get is mentioned there, but the context is different..)
https://netbeans.org/bugzilla/show_bug.cgi?id=128505 and Error with database in javafx DataApp demo
Any help is appreciated as I am still pretty new to continuous integration systems, developing web applications and build tools.
Also, I haven't looked much into Maven or Gradle yet as alternatives. So maybe the solution to the problem might as well be to switch to another build tool..?
It seems to me as if the property libs.MySQLDriver.classpath is not defined.
When Ant cannot resolve a property, it uses the property name in the output.
Try to define
libs.MySQLDriver.classpath
in the properties field in Jenkins where you also defined the other two properties.
You need to point it to your MySQL JDBC driver.
Building a JavaFX project from a directory on a networked drive is surprisingly slow. I believe most of the delay is caused by the build script deleting and re-creating the entire /lib directory. This includes over 20 MB of jar files that remain unchanged for my project.
How to I modify the ANT build task so that this lib folder does not get re-created every time I build the project? What else can be done to reduce the build time?
Another reason for the slow build time over my network is that the project always gets run from the /dist folder. For a standard Java SE project, a project can run from the build directory, removing the need to create a new jar file in /dist every time the project runs.
Is there a way to run the project from the .class files in the build directory instead of needing to run from /dist ?
Here are the netbeans generated build files:
jfx-impl.xml
build-impl
It would be helpful to see more of your build file, it is possible that the target dependency graph of whatever target your running could be changed. Put another way, make a target that doesn't delete lib/
A much larger and cooler solution would be to use ivy to download these libs one time to ~/.ivy where they'd be cached and wouldn't need to be fetched every time you checked out. This would allow you to shed those binaries from source control.
What reasons prevent you from building locally?
The suggestions below are only suggested for your development work based upon your description of slow build speeds in your environment. In general, if NetBeans JavaFX project development builds are already quick enough, the settings above should not be used. For packaging production applications you will want to use different settings.
How to get a quick build for JavaFX under NetBeans
Invest in a solid state drive.
Follow thekbb's suggestion of having the library files local to your machine.
Use NetBeans 7.4 + Java 8 and create a standard Java project rather than a JavaFX project.
Under Project Properties | Libraries uncheck:
Build projects on Classpath
Under Project Properties | Build | Packaging uncheck:
Compress JAR file
Build JAR after Compiling
Copy Dependent Libraries
Under Project Properties | Build | Deployment uncheck:
Enable Native Packaging Options in Project Menu
Keep JavaFX RT Artifacts on Compile Classpath if not present by default.
Under Project Properties | Application | Web Start uncheck:
Enable Web Start
If you end up being unable to solve your build performance issues using NetBeans, you might want to try Intellij Idea (I have found it quite efficient at building JavaFX projects).
My Build Experiences with NetBeans
A standard NetBeans JavaFX project builds and runs JavaFX projects very quickly for me (no more than a second or two). That is even without applying most of the build speed suggestions above. Projects which build in seconds reference over 75 libraries totaling more than 55MB of data. However, that build timing is when using local libraries, not when using libraries stored on a network. Also the quick builds are using a Macbook Air (which has an SSD).
If a project is signed, the signing process takes a few seconds per library jar.