Do any of the IDEs (or any other tool for that matter) have the ability to generate a POM based on an existing project?
I ended up generating the POM with a Maven archetype as Peter and Sal suggested and then moving the existing source in. Thanks for the help guys.
One way to do this it to create a template project via maven archetype then move your existing code to the template. I would recommend this only for really simple projects. It would work something like this.
mvn archetype:generate
mv src/* src/main/java
mv test/* src/test/java
mvn package
You'll get errors. To add the missing dependencies, go here: http://www.mvnrepository.com/ and start looking them up. If you pick an archetype close to what you need, you'll be half way there.
Once it all works.
svn commit -m "hacky maven port"
You can do this in IntelliJ, but the POM it generates may be more complex than if you write by hand. If your project is currently in JBuilder or Eclipse you can import this first.
Instead I would suggest you describe your project in a POM and use it to generate your project information. You can do this for eclipse and idea (and I assume other IDEs)
Your existing project probably does not use Maven, so creating a POM based on it isn't trivial.
The simplest way I can think of is to get the Maven plugin for Eclipse, generate a new maven project and then add your code.
You'll also need to manage external jars using Maven's method. In this case, they would probably be system jars.
In eclipse Galileo if you have the maven2 plugin you can select the project and then right click and go down to Maven2 in the context menu and there should be an option to convert the project to a maven project.
Related
I want to install eclipse plugin Agilereview from following link:
https://github.com/AgileReview-Project/AgileReview-EclipsePlugin
I downloaded the zip and unzipped it. I added it in eclipse as project and many projects added into workspace. When I tried to select all those projects and export them as deploy-able plugins in eclipse repository, eclipse doesn't allow it and always show error like plugin file missing. A problem is the zip file include many folders and many of those folder has its own plugin.xml file. Therefore, I think this Agilereview plugin itself is a combination of many plugins. I am sure that plugin is okay and its my mistake to install it.
Can anyone tell me, what is the mistake I am doing while installation? I want to install this plugin manually since later I need to optimize it.
Each of the folders org.agilereview.xxx is a separate Eclipse project. So you should use 'Import > Existing Projects into Workspace' to import these projects.
Since there are pom.xml files it looks like you should use maven and tycho to build the code.
For building RCP applications and plugins like Agilereview, which itself is a combination of many projects, you can check out the following tutorial:
http://www.vogella.com/tutorials/EclipseTycho/article.html
Eclipsetycho provides support for building eclipse components.
Install the maven eclipse tool, which will make your work easy.
http://download.eclipse.org/technology/m2e/releases
This is a pretty complex process, so spend some time to learn from the tutorial.
If i want to convert an EAR project a maven project , do i need to add the module in the deployment assembly as maven dependency or just use the convert in m2eclipse without any further configuration.
Me personally I wouldn't attempt any kind of conversion of an existing project. I would add the poms, make sure that mvn clean install works on the command prompt and then create a new mavenized Eclipse project from the poms.
The main reason is that you current project settings are effectively wrong when you switch to Maven - the Maven poms are the truth and what feeds the Eclipse project setup, so you really do not want to make your life difficult and work against m2eclipse - let it do the project creation for you. Fresh.
You can install m2eclipse and then do the following as well.
Go to the project menu (right click on Package Explorer) > Configure > Convert to Maven Project
Open the pom.xml and right-click and choose Run As -> Maven Clean. Similarly Choose Run As -> Maven Install.
Note : Please ensure that your eclipse project settings are correct and classpath libraries are not absolute and you don't have any project specific environment variables defined in your workspace. Please take a backup of your project before you do this.This is to ensure we don't mess up the current stable project configurations. Once m2eclipse generates the pom.xml for your project, you can update and make changes to it to
fully obtain a mavenized ear build. hope this helps
You can also try creating new maven project with archetype selection of "jboss-javaee6-ear" and follow the similar structure for your project. Most probably you will need parent Pom and child poms per each module (ejb, war, jar etc). There are other few similar approach but almost all of them requires you to have mulitple POMs
maven-ear-plugin and JBoss AS 7
You can also go through all the examples for maven ear plugin to find settings suitable for you
http://maven.apache.org/plugins/maven-ear-plugin/
I ended up ditching ear for war :) single POM and even ditched the JBOss for tomcat/jetty :)
If you want to convert your existing eclipse dependencies into Maven dependencies, you can try the JBoss Tools (JBT) Maven integration feature, which contains an experimental conversion wizard, plugged into m2e's conversion process : http://docs.jboss.org/tools/whatsnew/maven/maven-news-4.0.0.Beta1.html.
So, all you have to do is, as Keerthi explained, right-click on your project and Configure > Convert to Maven...
If your dependencies already are maven artifacts, it should work easily. If not, you'll need to convert them to Maven (if they're workspace projects) or make them available in your maven enterprise repository, before converting the EAR project.
JBT (requires Eclipse JavaEE) can be installed from http://download.jboss.org/jbosstools/updates/stable/kepler/ or from the Eclipse Marketplace (See https://marketplace.eclipse.org/search/site/jboss%2520tools)
I'm using eclipse with the m2eclipse plugin now I just want to resolve a - imho - easy problem: I've got two maven projects, I want to add project A as dependency to project B.
Well how do I achieve this in a manner way? If I add the project A to the build path of project B eclipse recognizes the classes but this project isn't resolved by eclipse on build time.
I got it working by installing project A to my local repo and adding this as dependency to my pom. This works but is cumbersome because I always have to install a new version of project A when something changed.
Shouldn't the plugin handle such a situation for me?
Providing that you have both maven projects open in your workbench then make sure you have the "Enable Workspace Resolution" option enabled in the Maven context menu.
Yes Eclipse handle this situations.
You can add both the Projects A and B in the same work-space.
I could help you creating a simple work-space from the scratch.
I am assuming that you have already installed the MAVEN plugin M2Eclipse for Eclipse.
Start a new Eclipse in a blank Work-space
Right click on Project Explorer --> Go to Import dialog and add a Maven Module.
Locate the POM directory and add that directory.
It will list all the projects in all the sub folders.
Add as many as Maven Based modules in a single work-space.
By doing this you dont need to install the dependencies. Any change will be reflected on the derived module.
Hope that will help you.
The way you did it is correct, because it assumes that project B will be using the dependency of project A that will be in the artifactory, so you can develop both independently.
And anyway, for the project A, if you are using maven, don't you use maven clean install for compiling and deploying? That way you are sure you always have the latest version
The other option is, in case both of the are more dependent of each other, you should consider make one of them as a module of the other, or maybe make a project C that contains both modules, but that would mean both of them are part of the same project (like an ear containing two jars), depends on the situation
I've been asked to apply Maven to a project. After browsing a dozen sites it appears that it's quite vast and I'm not familiar as I'd like with similar tools like Ant. Why is it used/preferred and what does it offer over a standard Eclipse project? Also, how could it be added to an existing project?
Why is it used/preferred and what does
it offer over a standard Eclipse
project?
It is a build tool which can build your project without the need for an IDE like Eclipse. It can create a jar or war or other artifacts from the source, performing a bunch of steps like compilation, running unit tests, etc.
Where maven scores over ant is in managing third-party dependencies and in convention over configuration (which mean less lines of build script if you follow convention).
Also, how could it be added to an
existing project?
You start by creating a new maven project, following the step here.
Place it in the root folder of your project
If your source and resource files do not follow maven folder convention, update maven properties suitably referring to this documentation.
Run mvn package
It will fail if it needs any third party dependencies, which you can add as specified in the doc
With some trial and error, you should have your project running with maven, possibly, much quicker than if you were to set up the same with ant.
Others are already provided sufficient resources to read more about maven.
I suggest to start reading here:
http://www.sonatype.com/books/mvnref-book/reference/public-book.html
Maven is a great tool when you know how to use it. Maven (at core) is a dependency manager.
You include in your pom.xml (similar in function to the build.xml from Ant) all the librairies your project depends on (example : apache commons) along with their version and Maven get them directly from a repository (by default, the central maven repository)
Then you do not have to manually install any jar to make your project work. All is downloaded and cached on your local machine. You can even create an enterprise repository where you put all the jars needed by your company
Maven uses the concept of artifacts which are pre-built library projects with their own dependencies
To mavenize a project, you'll have to write a pom.xml describing your project (examples are numerous), get rid of your libs directory (or whatever classpath you described under Eclipse) and add all your dependencies to your pom.xml
You could also check Mavenizer for a first-start
But Maven is a lot more what i've just said. Read the docs, read poms from librairies and you'll get used to it quickly ;-)
If you use the M2Eclipse plugin from Sonatype, it's just a matter of right clicking the project in the package explorer and choosing Enable Dependency Management in the Maven menu. You are also advised to adjust the directories that contain the sources to the Maven standard directory layout but if you absolutely can't, you can configure that later.
Apart from that: Well, look for tutorials and documentation (for example there is the free book Better builds with Maven. Maven is very complex (yes, I don't think it is simple) and very powerful.
I will ask my question short and sweet, is there any formal way to write code using IDE and then build them using manual build process.If anyone has good links on internet, it is better to give
I believe it's easy, and what is more important - convenient, in cases when your IDE project is based on some external build model e.g. Ant, Maven, probably SBT for Scala. In this case it's easy for external build to be synchronized with IDE. Also it's important whether your IDE monitors underlying filesystem changes inside project folder, as I believe it's going to be quite pain-full to click "Refresh" or something similar every time you build.
Popular IDE's provide options to import project from external models like Ant and Maven.
Personally I use this approach in one of my projects with Java, Maven and IntellijIdea.
Yes. Use maven. It has plugins to all popular IDEs. So, create maven project, write pom.xml, run mvn install and then run mvn eclipse:eclipse (if you are using eclipse).
This will produce .project and .classpath. Now open eclipse, define classpath variable M2_REPO and import your project.
M2_REPO should be defined only once and should refer to local maven repository that is typically located under USER_HOME/.m2/repository.
For more details see documentation of maven.
I did not know this and always spent a lot of time synchronizing my IDE and ant build.xml. But now I am using maven and can forget about this hard work.