- This topic has 5 replies, 2 voices, and was last updated 15 years, 11 months ago by tames.
-
AuthorPosts
-
tamesMemberSince my favorite web framework, Wicket, utilizes maven, I thought I would try Maven4MyEclipse.
I have the local repository working, and I have Maven Dependencies in a project.
Here is what I would like to do if it is possible:
Since most of my web projects require a base set of dependencies, I created a Java Maven Project as a template and added all the dependencies. I ran the “package” and “install” to place this in the repository. There is no source or class objects in this project. The pom.xml that was created shows the correct dependencies.
The next thing I did was to create a Java Web Project with Maven support. I clicked on Add Dependency, and found the template project I created above. I clicked OK with the scope set at compile. What I was expecting to happen was to see the Maven Dependencies under the web project, but it did not show up.
Do I have to add all my base dependencies to every web project or is there some way to make this happen with a template?
Before Maven, I was using User Libraries to group my base jars. This worked great. I was hoping that Maven had this kind of thing built in.
support-eugeneMember@tames wrote:
Since my favorite web framework, Wicket, utilizes maven, I thought I would try Maven4MyEclipse.
I have the local repository working, and I have Maven Dependencies in a project.
Here is what I would like to do if it is possible:
Since most of my web projects require a base set of dependencies, I created a Java Maven Project as a template and added all the dependencies. I ran the “package” and “install” to place this in the repository. There is no source or class objects in this project. The pom.xml that was created shows the correct dependencies.
The next thing I did was to create a Java Web Project with Maven support. I clicked on Add Dependency, and found the template project I created above. I clicked OK with the scope set at compile. What I was expecting to happen was to see the Maven Dependencies under the web project, but it did not show up.
Do I have to add all my base dependencies to every web project or is there some way to make this happen with a template?
Before Maven, I was using User Libraries to group my base jars. This worked great. I was hoping that Maven had this kind of thing built in.
I tried to reproduce your issue. I did the following:
1. Created library project with group ID “com.genuitec” and artifact ID “library”
2. Added dependency:<dependency> <groupId>commons-attributes</groupId> <artifactId>commons-attributes-api</artifactId> <version>2.1</version> </dependency>
3. Verified that 3 jars were added to the “Maven Dependencies” library container.
4. Right-clicked library project in the project explorer and chose “Run As…->Maven Install”
5. Created web project with Maven support.
6. In the package explorer pop-up menu chose “Maven4MyEclipse->Add Dependency” and added the library project.<dependency> <groupId>commons-attributes</groupId> <artifactId>commons-attributes-api</artifactId> <version>2.1</version> </dependency>
In the package explorer I saw a project from the workspace and 3 jars added to a web project (see the screenshot). I believe that is what you are trying to achieve.
I also tried removing the library project from the workspace – MyEclipse successfully picked the repository artifact.So the questions are:
1. What MyEclipse version do you use?
2. Did you change any Maven-related MyEclipse settings?
3. Can you try running “Maven4MyEclipse->Update Dependencies” manually?Notice: Step 4 (installing library artifact into repository) is unnecessary – as long as you have it in the workspace ME will use the project instead of repository artifact.
Attachments:
You must be logged in to view attached files.
tamesMemberI am using 7.0 M2, Build id: 7.0-M2-20080915
Your test is not exactly what I did. If you look at your test, you added the same dependency (commons-attributes) to both projects. Let’s say you had 10 dependencies to add This is what I am trying to avoid. Having to add the same 10 dependencies to every project.
What I want to do is just add the commons-attributes to the first project (com.genuitec) as shown, then add the com.genuitec library project to the web project. In doing that, I was hoping that all dependencies that com.genuitec needed would be available to the web project. I have not researched into the actual Maven utility to see if this is possible even outside ME.
One example of this that I have seen is with the base wicket jar. When I add the wicket jar with Maven4MyEclipse, it also brings in the slf4j-api jar file which I did not select. I don’t quite understand how this is doing this, but I was hoping Maven4MyEclipse could help with this kind of thing.
One work around I have found is to create the “dummy” library project then copy the <dependency> xml statements into the web project.
This leads me to one enhancement you may want to consider. On the Add Dependency search screen, you have to add one at a time. This can get quite laborious if you have several to add to your project. I was hoping to hold down the Ctrl key and select multiple.
support-eugeneMember@tames wrote:
I am using 7.0 M2, Build id: 7.0-M2-20080915
Your test is not exactly what I did. If you look at your test, you added the same dependency (commons-attributes) to both projects. Let’s say you had 10 dependencies to add This is what I am trying to avoid. Having to add the same 10 dependencies to every project.
I only added library project dependency. Other dependencies were picked from that POM.
Attachments:
You must be logged in to view attached files.
tamesMemberIn your first reply Step #6, was that an error in your screenshot? Because #2 and #6 are the same dependency. The text for #6 said you added the library project, your screenshot says you added the commons dependency.
If indeed the screenshot is wrong. Then what you did is not working for me.
tamesMemberI got this to work one time. I remembered seeing a setting somewhere about SNAPSHOTS. I changed my library project to be a regular release. When I did this, installed into repository then updated dependencies on the web project. What I was expecting showed up just like it did for you.
Bad news:
1. Since that time, I have deleted the web project several times and tried to add the library dependency again. It will not work.
2. In my workspace I only have these two projects. When I did an update dependencies on the LIBRARY project, the Maven Dependencies folder disappeared in the WEB project. The pom file in the WEB project looks fine. I have tried updating dependencies on the WEB project, but I cannot get the Maven Dependencies folder to reappear. I have to completely delete the WEB project and recreate. -
AuthorPosts