I have created java desktop application project using NB and now I want to convert it into maven project so everybody will be able to compile it and maintain in eclipse/netBeans. Is there any easy way to do this?
Or maybe there is some way to convert project created using wizard in NB to eclipse?
I'm currently doing this for an Enterprise Application, which consists of 3 modules (EJB,EAR and WAR).
Its as simple as creating the new Maven project and copying your .java files into the new project and dependencies into the pom file.
Related
I have a Maven project in SVN with trunk\Config\TestProjConfig folder having all the XML configuration files and all Java code is in trunk\JavaSource\TestProj. When I check out to my local Eclipse there are 2 projects created one for TestProjConfig and one for TestProj.
How do I test this project? Do I have to edit the build path to make a connection between the two projects? Do I have to write a main class which accesses the AppContext file to invoke the Spring injections?
Note:I have the m2eclipse plugin in Eclipse.
I don't understand why you separated XML configuration from Java sources. It could be a good practice only if you want to reuse your conf in other project, but in this case, I'm not sure that's suitable.
Solution 1
Move all your xml config into JavaSource\TestProj\src\main\resources
If you really don't have to share your configuration or don't have any legacy / corporate / mysterious reason, you should not separate them.
Solution 2
If you REALLY want to separate them, put them in a zip with an assembly, and add a dependency from TestProj to TestProjConfig.
Here an example : Maven - Depend on assembled zip
I have created in Eclipse Dynamic Web Project. Then I have selected option 'Convert to Maven Project' from 'Configure' from right-click menu. And now I can see red errors on Java Resources folder in my project. But none subfolder is with red error. In which way can I resolve that problem? I am using Eclipse Juno and m2e plugin.
I have recognized that m2n plugin haven't created src/main/java, src/main/resources and src/main/webapp directories in Java Resources. But the error is still the same.
The process in manually. You need to create a pom.xml and change your folder structure to follow Mavens conventions. I would recommend to create a web project via maven archetypes and move your project step-by-step into the new structure.
How to integrate maven 2 in an existing netbeans project ?
I dont want to do it by creating a new maven web app project and moving my files manually to
the new project(as I have versions of this project in my subversion repositories which I wont be able to link if I create new project), rather I need to integrate that in my already existing netbeans project. How do I go about it ? Would creating a pom.xml work ?
Maven 2 already installed on my machine.
What about creating a new Maven Web Project and moving the pom.xml back to your existing Web Project? I mean:
Backup your projects
Create a new project with name MavenWebTest
Close your original project
Move the pom.xml from the MavenWebTest project to your original project's folder
Modify the pom.xml's project specific settings (e.g. project name, dependencies)
Delete the build.xml and the whole nbproject folder
Move and rename the web folder to src/main/webapp (webapp is the new name) (use svn mv if you use Subversion)
Move src/java to src/main/java (svn mv here too)
Open you project again in Netbeans. It should be a Maven project now.
Delete the unnecessary MavenWebTest project
Anyway, creating an empty pom.xml also should work. You have to list your dependencies in the pom.xml and you have to set the project's name. Maybe other fine tunings also required to get the same result as Netbeans create without Maven. If you create the pom.xml with Netbeans (the MavenWebTest above) I suppose that most of Netbeans specific stuff already will be there.
If you are new to Maven I suggest you to check the free pdf/html books on Sonatype's website.
I read some articles about how to set up eclipse and maven to create a new empty ear project but all solutions weren't complete or are to old.
I believe that I need to create three pom.xml files / or three projects:
client project with the WEB-APP structure (like a regular dynamic web project).
This should result in a WAR file.
server project with the ejbs. This should be a JAR file.
ear project which joins both projects together.
I tried that with help of the integrated maven plugin in eclipse. Since (I believe Helios) maven is already integrated in eclipse. So I go to
file -> new -> maven -> maven project
and leave the "create a simple project" checkbox unchecked. On the next side I got the archetype catalog. To create the client project I looked for maven-archetype-webapp Version 1.0.
But all the folders like WebContent\META-INF etc. are missing.
So how can I create all three projects are build them together?
Thanks a lot,
Hauke
PS.: I read in question 5668710 about creating the project without maven and activate the dependency management. But is that the right way? I don't think so.
Creating the projects via console and importing them via m2eclipse would be the best way, as you can read it in the comments of your question.
Start off with this line in your console
mvn archetype:generate
Then use the archetype maven-archetype-j2ee-simple
This will generate you a project structure for ejb, ear and web projects. Otherwise you can create 3 simple projects maven-archetype-quickstart on your own and add the concering plugins
maven-ear-plugin
maven-ejb-plugin
maven-war-plugin
Here is another post, handling your problem: Maven2: Best practice for Enterprise Project (EAR file)
Another nice example you can find here
The best and the most clean way for creating an Enterprise Application (all the three projects ear, jar, war.... i.e. jar and war are linked into ear).... is to create through maven Enterprise Application in NETBEANS and import the whole project into Eclipse.
Thanks
Imran
Inside the folder 'ProjectName' exists several subfolders, and of them contains java program:
ProjectName
Specifications
JavaCode
Gfx
...
JavaCode folder contains pom.xml.
I have installed m2eclipse (0.10.x) to Eclipse and imported whole ProjectName folder to Eclipse. Subfolders are displayed correctly but maven integration is not working correctly - for example I don't see src/main/java "shortcut" folder in Eclipse, but I have to click to open all folders.
If I create a new maven project with Eclipse from scratch, the integration works well.
What could be the issue?
Select the JavaCode folder and then invoke File... / Import... / Maven Project. That would bring your Java code into Eclipse as a proper project with Maven support enabled. It is fine to import several overlapping folders. So, you could use the parent for version control purposes and JavaCode would be the actual Java project you'd work with in the IDE.
Unfortunately there is no way around that, unless you want to move your pom.xml to the root project and remap all the Maven plugins to folders under JavaCode project. But that would be really bad idea and Maven integration for Eclipse may not work with such project structure without an additional tweaking.