I tried to create a project in WTK which I'm using for SVN commits. My problem is that every time I create the .jar package those .svn/ directories appear in it...
Is there any build script the Wireless Toolkit uses that I could modify to avoid including .svn folders to the packages? Or maybe better solution?
You can build an Ant script to package explicitly the directories you need using the jar task. Ant also includes an SVN extension to allow exporting a clean tree without the .svn files. Ant by default excludes .svn directories as noted here.
Related
I currently have a basic Java project, that I want to deliver as an executable JAR. The program within it is based on several resource files, which must be editable by the user, or by a third-party program, which means that those files must not be embedded into the JAR archive.
I am using Eclipse to develop my project. The question is :
How to make the exportation of those files automatic, to end up with the JAR, and right next to it, a folder containing the resources for exemple (if that is possible of course) ?
Every thing I've tried or found on the net concerns resources delivered within the JAR, which avoids any modification of those resources. The ideal solution would copy the files right next to the JAR when it is exported.
Eclipse's "export executable JAR" functionality can't do this directly, it's limited to the contents of the JAR. I recommend you investigate doing this with a build tool like Gradle, Maven, or Ant, and then invoking that from Eclipse or via command-line.
I have inherited an old java project, where different team members are using different development tools; some use emacs, some netbeans, I use eclipse. Hence when this project is checked into the version control, it's just a bunch of java files and ant build files.
Every time there is a new branch or so, I checkout the project in my eclipse through subclipse plugin and generate some dependent jars, put them in classpath, then set up the source folder etc etc. This is becoming very tedious as I help out others with same configuration if they're using eclipse. Is there a way I could have some script which I can run on the project to convert and restructure it to an eclipse project?
You could have the Ant build create the .project and .classpath files for you. I've done this myself with the XMLTask suite, since those files are just XML documents. Add them to the svn:ignore property so your twitchy teammates don't get upset.
There appears to be an old ant task that does this for you, but I haven't used it myself.
I am trying to modify the message monitoring plugin in Openfire.
I checked-out the code using svn. And i could also figure out what and where i will need to change the code. But I am not clear about rebuilding the plugin and testing my changes.
In Eclipse, I can export the "plugins.monitoring" package as a .jar, but it does not export all the classes. For example, it exports plugins.monitoring.src.web but ignores classes in sub-packages (if i am not wrong with the term) such as plugins.monitoring.src.java.org.jivesoftware.openfire.reporting.util.
How do I compile only one package and export it to .jar file?
Thanks
I got how to do this. It is to be done using ant
build.xml can be found in the build directory inside the Openfire source code
In the eclipse directory, there is .classpath file. What's the purpose of this file?
I have ant build.xml available, why Eclipse still need its own?
Eclipse has its own mechanism for building your project. The .classpath file contains information that the IDE uses to create the classpath used at build-time, runtime etc. You can directly edit this file if you want but it is created by the IDE based on the settings that you provide via the project properties dialog.
There is Ant integration within Eclipse insofar as it provides you a specific editor for build files, but it can't use any of the information in the build file for its own builders. Ant files are custom, so there is no way Eclipse could know what info to use.
The reason for this is that it doesn't matter if you have an Ant file or not. The reason for the presence of this file is that this is a Java Project, and the corresponding Project nature always generate such a file. Create a normal Project (New->Project->General->Project) and you'll see that there is no .classpath file.
In general I would recommend to split those functionalities in separate projects, that means one Java Project for developing, one non-Java-Project for executing your Ant scripts.
HTH Tom
What are the best practices (and enabling tools) to deploy Java standalone applications along with any required jar dependencies, config files, and launch scripts?
Are there any Maven plugins that easies publishing binary releases, so that users don't need to use maven for example?
Are there any Maven plugins that easies publishing binary releases, so that users don't need to use maven for example?
Use the Maven Assembly Plugin to create a binary distribution as zip/tar.gz/tar.bz2 of your project. This plugin is extremely flexible - at the price of some complexity - and you can do almost anything you want. Then deploy (in the maven sense) the produced artifact, upload it somewhere, etc.
As for dependency, I just use maven dependency copy plugin and copy all dependencies into a ./lib folder, and supply a launch script that uses the class path wildcard (that way you can change your dependencies as much as you want and don't have to change the launch script). As for configuration files, I put it in a ./config folder and again include it in my app's classpath in the launch script (The former admittedly only works for > java 1.6).
So in the end almost all my app has the following structure:
mystuff.jar launch.sh
./lib
./config
Then I'll just zip up the whole thing and give it to my users. The whole process is probably easy to automate using maven, but I confess that I do it by hand :p
If you prefer and the licenses permit, you could also just bundle all dependencies into a single jar (with expanded dependencies inside) using the assembly plugin. This tends to make the jar bulky and giving the users an updated app. more difficult. Also I had issues with it several time because of class files getting overwritten or something so I personally stick to the ./lib folder.
There's launch4j, which, if you can get it to work, will bundle up a Java app into an executable for your platform.
If your deployment target supports RPM files, I strongly suggest you investigate the rpm-maven-plugin. It allows you to easily map your project artifacts , including dependencies, to a RPM package.
I've been using it with great success to medium-scale application deployment.
You can use Oracle's ant or maven scripts:
http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm
The above will not only compile your code and create jar files, but it will also create binary executable (windows exe file or Mac app file). It can also create native installers. In addition it lets you include JVM with your distribution so the end use doesn't need to install Java.
Take a look at the Appassembler Maven Plugin. You may also want to combine it with the Assembly Maven Plugin.
Use the appassembler plugin to generate a set of "programs" by specifying executable names and main classes. You can also have it prepend and create an etc directory in which you can add configuration files.
If generating the directory with the start-up scripts and directory of binary files isn't enough, you can use the assembly plugin to copy over additional files (say your configuration files) into the appropriate directory and/or package your application into an archive.