How can I use Arquillian without Maven? - java

I'm making my first Java EE project and can't figure how to test my EJB. I've read that Arquillian is really useful to do integration tests, but it seems like using it without Maven is difficult. Could someone tell me if there is a way to use it or a tutorial?

Are you using any sort of dependency management tool, eg Ivy? I really recommend using one, since it makes things much easier.
That said, Arquillian does not use Maven itself, so you can use it without Maven. You will just have to figure out which dependencies you need. You can either work it out by just looking at the Maven POM files, or you could start with a sample Maven based setup and use the maven-dependency-plugin to export the libraries you need. See also https://gist.github.com/mojavelinux/2363038.
Personally I would recommend to just use a dependency management tool, be it Maven or Ivy.

Related

Can't find jar files in spring framework 4.0.6?

Today, i donwloaded Spring Framework 4.0.6 latest version but unable to locate the jar files, and i donwloaded eclipse plugin for spring too, here i find nothing and looking for a way to include these jar files into eclipse, here is a pic.
Some tutorials website refers that it contains into lib folder but i can't see it, please help!
It sounds like you have a number of hurdles to overcome:
How to use Eclipse
How to manage Java dependencies
How to use Spring
I'm not sure what your level of experience is, but you may wish to consider using Spring Tool Suite as your IDE - it's based on Eclipse with additonal plugins to aid Spring development.
I also urge you to use Maven or Gradle to manage your dependencies. The Spring documentation provides the configuration for adding the dependencies in both. I'd recommend Maven as a starting point as it is easy to use with little knowledge and is well suited to small, standard projects. Gradle is worth a look once you are comfortable with Maven.
Work though the Guides - I'd start with 'Building Java Projects with Maven'.
Edit
Maven is a dependency management and build tool that favours convention over configuration. Dependency management is powerful in that you can declare a dependency on Spring Core, for example, and it will download all the related dependencies for you.
Gradle performs similar functions to Maven but also provides the ability to use scripting. Gradle is seen by many as Maven's predecessor and has been adopted by Spring over Maven.
In my opinion Maven is easier for you at this stage.

Dependency management for a small Java project

What is the best practice when it comes to managing dependencies in a small java project? Small meaning one Eclipse Java project. I have 4 different third-party jars that I have added to the Eclipse build path. I have had experience with Maven, but for this small scope, it doesn't seem like it would fit. I have read about Gradle, but have not tried it. What's the best way to approach this?
I recommend Apache IvyIDE.
http://ant.apache.org/ivy/ivyde/
It allows you to manage your dependencies declared in an ivy.xml in your Java Eclipse projects.

Maven Java API : Standalone Dependency Resolution (i.e. not a Maven plugin)

I've been trying to develop a relatively simple application (used as pre-cursor to a custom build process) which will process some POMs and resolve all the dependencies in advance (transitevely) from a remote repo.
I've succesfully been able to extract various properties from the POM (which I'm making use of elsewhere), but the dependency resolution is proving to be rather difficult.
I have experimented using various classes from org.apache.maven and also looked into Aether. I've poured over many resources online regarding dependency resolution with org.apache.maven, however they all seem to cover Maven plugins (which hook into the Plexus container with annotations) rather than a standalone application, where I don't [believe I] have access to that container and so cannot use the sorts of objects I need, such as an ArtifactResolver or ArtifactRepositoryFactory.
Is there a way to get the Plexus container when not being executed as part of Maven? If so, are there any good resources for explaining this? If not, are there any implmentations of the key classes which don't require the Plexus container?
Two open source projects that may answer your questions are Ivy and Leiningen. Both connect to maven repos to do dependency management, but don't seem to use the maven command line. Note that Leiningen is for Clojure projects, so it may be difficult to understand if you don't know Clojure. I have never looked at its source though. For all I know, it's written in Java.
Have a look at Eclipse Aether, there is an example that does just that.

Is there anything like pkg-config for Java?

I have a project where our CLASSPATH is getting out of hand. We have jars that depend on other jars, which in turn depend on even more jars, as well as a large collection of third-party jars. So each time we use one of these jars we need to construct a rather large CLASSPATH, and if downstream dependencies change it is no longer in sync.
One thought is to maybe write a tool a little like pkg-config to help with all of this. I did some searching and didn't find anything. Are there any tools like this that I've missed or do people have alternate solutions?
No, I don't want to use Maven. We already have a different build system in place.
If you aren't already using a build tool, I recommend starting with Maven. The main thing that turns people off Maven is that it has a standard project structure. Personally, I think that's a good thing.
If you want to be a little more free-form with your projects, there are the Maven Ant Tasks for Ant. I much prefer these to Ivy, but part of that is because I'm used to the Maven artifact naming conventions.
In either case (or if you use Ivy), look into a repository manager. Nexus is written by the people who maintain Maven, and I find it easier to use than Artifactory, which is another widely used system. One benefit for Artifactory is that they provide hosting (for a fee).
You may want to use maven with an IDE plugin like m2eclipse. All you have to do is type the class in your code and it will help you search for and bring in the right packages with their dependancies. It will also automatically configure the classpath for you. Here is a quick tutorial http://www.sonatype.com/people/2010/03/adding-dependencies-using-m2eclipse/

A basic question on java/maven/testng

I am using RHEL 5. I want to be able to write a basic Java class, write corresponding test methods using testNG and be able to say something like "mvn install" which will run test cases and install the built jar.
Is there something called maven plugin to support testNG on RHEL? or there is no such thing and above can be achieved by default on linux. ALso how?
The usual maven plugin for testing, the maven-surefire-plugin, handles testng as well as junit.
There are a number of plugins for Maven that will auto-run your tests. I would suggest starting with an IDE solution, such as one provided by the Spring STS eclipse-based suite, which has pre-built project templates, including *.pom files already set up.
If you are looking to do more than that "out of the box" functionality, reading through the Maven docs and perhaps a book would probably be a good idea. In general, whenever you have a really powerful and flexible tool like Maven, things can get complicated really fast, so having a solid understanding is critical to be able to use the tool successfully.

Categories

Resources