How do I build MWDumper from source? - java

Java newbie here. I'm trying to run the latest version of MWDumper, which is a command-line utility that imports wiki databases. The page said I should build it from its source. I've downloaded the source-code. They've got a makefile and a build.xml. How do I build this?

You need to install ANT and run ANT in the folder containing the build.xml.
If you're on linux or mac it's pretty easy - you just [package manager name here] install ant;
You then just cd to the appropriate folder and type in ant. It should build your app.
You also need to make sure that you have the Java Development Kit installed for the ANT to use. Ant doesn't actually do any compiling, it's just a tool that reads build instructions and calls various applications and compilers to output the end executable (or similar product).
You should be able to install 'jdk' from your package manager, or from their site (http://www.oracle.com/technetwork/java/javase/downloads/index.html).
If you're on Windows, you can install the JDK from the same link, and you can follow the following link as a guide to install ant for windows: http://ant.apache.org/manual/install.html
Don't forget to add the path to ant to your environment 'PATH' variable! :) (more details in the link above)

Use Apache Ant.
cd <dir>
ant <target>
Also you can use Apache Maven.
cd <dir>
mvn install

Related

Equivalent of "make install" in the Java world

TL;DR: Is there a standard way in the Java world, to have the build tools install the executables they just built (like the make install of the C world)?
(I would be happy with a solution that would work only on Linux)
More details:
I have a Java project distributed via github. Compilation and dependencies are managed with maven 2. Running mvn package builds a tarball with my jar and the dependencies needed at runtime, plus an executable script which set the classpath and launch the main jar:
#!/bin/bash
cpBase="$(dirname "$0")"
java -cp "$cpBase/*" dw.cli.Program $#
So, if someone wants to install this on her computer, one need to:
run mvn package
and then to unpack the tarball and to copy the content in a directory on her PATH.
On the other hand I like the way the autotools are working: the user doesn't need to copy anything manually, because the build step make install handles the installation for her.
I could emulate this behaviour using cp through ant tasks in my pom.xml, but I'm more interested in learning the Java good practices than to provide non standard behaviors.
It seems maven doesn't provide this behavior. On the other hand, I'm totally ignorant of what the other Java build tool can do wrt to this.
Edit:
As far as I understand mvn install and mvn deploy don't fit my need, because they will install my jar in my local or remote repository. Whereas I want to install my executables on my PATH (eg: to install my wrapper script in /usr/local/bin)
The question is tagged "gradle", so I'll supply the Gradle answer.
I take it you're building an application, not a library. In that case, Gradle is thoughtfully supplying the application plugin.
apply plugin: 'application'
The plugin will supply you the run, distZip, distTar and installDist tasks, which do just what they sound like. Check out the documentation at
the official web site.
Note that the installDist task doesn't, by default, put the software anywhere centrally on the system. Rather, it will install in a subdirectory of build, where temporary files are kept. You could set the destinationDir property on the task to remedy this.
You can created a distribution archive (zip, tar.gz) which can be downloaded by the user and only needed to unpack and add the bin folder to the path.
The problem is that you can't automatically enhance you path environment variable. But if you use the generated scripts from appassembler-maven-plugin you can simply can call directly the generated scripts without enhancing your path. This works on linux as well as on windows.
This can be achieved by a combination of appassembler-maven-plugin and maven-assembly-plugin.
The appassembler-maven-plugin will create the appropriate shell/bat/cmd files for you and the maven-assembly-plugin can create the appropriate archives (tar.gz, zip) for you.
As an example you can take a look here:
https://github.com/khmarbaise/supose/tree/master/supose-assembly
"make install" works by copying your built artefacts into their target location. This behaviour is quite easy to emulate in ANT, because like make it allows you to specify your own build logic:
<target name="install" description="Copy binaries into install location">
<mkdir dir="/opt/myapp/bin"/>
<copy file="${dist.dir}/myproject.jar" todir="/opt/myapp/bin"/>
<copy file="${dist.dir}/myproject.sh" todir="/opt/myapp/bin"/>
<chown owner="${install.owner}">
<fileset dir="/opt/myapp" include="**/*"/>
</chown>
</target>
Course you'd have to run this target as root:
ant build
sudo ant install
Maven on the other hand is a highly opinionated build tool that does not support this kind of workflow. Why? This is really a deployment action. Of course you can customize the Maven setup using ant ANT plugin, but I'd advise to just have a shell script you run afterwards. Lot easier to understand:
mvn install
sudo install_myapp.sh
The script can pickup the built jar from the Maven local repository "$HOME/.m2/repository" or better still download it from a Maven repository!
You have other mvn goals like 'mvn deploy' and 'mvn install' that do what you need.

What packages are required to package a DEB file in Netbeans?

I am trying to package a Java SE project with Netbeans Native Packaging. While there are plenty of instructions for doing this on Windows, I cannot find the required packages for doing so on Ubuntu with a Debian package.
What do I need to install on my system to make this work?
if you're free to choose a buildsystem there're rpm and deb packaging plugins for gradle, maven and even ant tasks for deb and rpm.
The resulted packages are somewhat limited, but if you don't something special like precise file permissions control, or rpm install triggers etc, they may help you.

Maven - Windows installer plugin

do you know a highly configurable maven plugin for creating MS Windows installers?
The artifacts of my project are processed through a Maven Launch4j plugin, therefore I already have an executable (*.exe) file, but I need to install the other dependencies and resources as well: *.dll, images, the executable and so on. I also like to install the jre (if required), set some environment variables and so on.
Can you recomend a plugin?
Best regards.
I think you are looking for the nsis-maven-plugin
The nsis-maven-plugin enables Maven integration with the NSIS tools so
that Windows and Linux build machines can create Windows Installer
EXEs.

Using Eclipse ant plugin from command line?

I know this is not a smart question.
I need to use ant from command line and there is Ant plugin in Eclipse, so I have tried to specify ANT_HOME in Eclipse to be set to the directory of that plugin.
C:\Users\Nikolay>ant
'ant' is not recognized as an internal or external command, operable program or batch file.
Should I install a separate Ant from Apache to enable Ant from command line?
Probably the best solution is to install ant, but you can use the binaries that are from Eclipse too. You will find the binaries under eclipse\plugins\org.apache.ant_1.8.2.v20120109-1030. Note that the plugin the version may be different on your machine. Something like:
${eclipse_location}\plugins\org.apache.ant_1.8.2.v20120109-1030\bin\ant
should work. But this should be used only for solving something quick, until you can install ant. Since you will upgrade your Eclipse/plugins and the paths will change and you will need to keep updating your environment variables this way.

including jars in clojure

I have downloaded and installed a jar with Maven (as answered here) but now I need to require it inside of a project. I followed the instructions on the git README ((require '[clj-http.client :as client])) but I still get this error:
FileNotFoundException Could not locate clj_http/client__init.class or clj_http/client.clj on classpath: clojure.lang.RT.load (RT.java:430)
The other answers on this thread will certainly work .... But adding jars directly on your machine's CLASSPATH or at the command line can be a very difficult strategy for development . . .
The most common, idiomatic way to include jars in a clojure app is Leiningen (easy, one step install on github -- begginers should check note at the end of this answer for a caveat)... Leiningen can also install the clojure environment and launch your repl for you, preloaded with the right jar environment.
It is essentially a java dependency manager and build tool rolled into one - i.e. like ivy or the maven Pom.xml which we use for java development.
A Few examples of how to use Leiningen to interact with multiple libs in a simple and scalable fashion :
To launch a repl, such that the jars in your project.clj file are on the classpath :
lein repl
To update your jars in your maven repo specified by your project.clj :
lein deps
Finally , lein let's you export "uberjars" which are akin to "fatjars", i.e. they have all the dependencies bundled for you.
A minor update regarding the new Lein version : Note for begginers.
There are two scripts you can run to install Leiningan, it might be safer to run this one:
https://github.com/jayunit100/leiningen/blob/stable/bin/lein (the stable release)
Rather than this one:
https://raw.github.com/technomancy/leiningen/preview/bin/lein (the latest update, which is a preview).
when you start the java process you need to do:
java -cp ./lib/clj-http.jar ./lib/clojure.jar clojure.main
Basically you need both clojure.jar (which is where the REPL is at) AND clj-http.jar in the classpath.
Assuming clj-http.jar is in ./lib/ directory. Or you could build your project with lein (build tool, similar to maven) and have it build an uberjar, which is what I would do. There's a pretty good walkthrough of setting up lein and building an uberjar here: http://zef.me/2470/building-clojure-projects-with-leiningen.
add clj-http.jar to CLASSPATH or CP before you start clojure repl.

Categories

Resources