I'm trying to make a simple log in/ log out web application with maven and I'm creating the project with the command: " mvn archetype:generate " and choose 341 and it'll be created with the structure below:
webapp
-----src/main/java
-----Referenced Libraries
-----Maven Dependencies
-----src
-----target
pom.xml
But when I add some dependencies and update the project something weird happening with the structure of the project according to the picture below:
webapp
-----src/main/java
-----Referenced Libraries
-----JRE System Library
-----src
-----target
pom.xml
and it's not working any more.
As you can see the the first one has a Maven dependencies Library but the second one has been changed to JRE System Library.
I use mac os lion and eclipse indigo.
Anyone how knows why is like that?
Tancks
eclipse:eclipse makes maven re-generate Eclipse .project file which contains the Maven nature. You may want to look at additionalProjectnatures parameter or not use eclipse:eclipse
Edit: http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html#additionalProjectnatures
Related
I created an Ext project with Maven:
mvn archetype:generate
mvn package
mvn eclipse:eclipse
mvn install
This actually builds 9 different ext "sub projects":
<project_name>-ext
<project_name>-ext-impl
<project_name>-ext-lib-global
<project_name>-ext-lib-portal
<project_name>-ext-services
<project_name>-ext-util-bridges
<project_name>-ext-util-java
<project_name>-ext-util-taglib
<project_name>-ext-web
The root project <project_name> has its own pom.xml.
Each of the 9 sub directories have their own pom.xml files and generate a JAR or a WAR file.
I imported all from the root into eclipse. This actually imports the root project and all of the 9 sub projects.
I followed the doc guide to modify portal-ext.properties:
https://www.liferay.com/fr/documentation/liferay-portal/6.2/development/-/ai/developing-an-ext-plugin-liferay-portal-6-2-dev-guide-12-en
This doc was written with an Ant build so I tried to make it using Maven but I probably missed something.
I set the updated portal-ext.properties version into:
...\<project-name>\<project-name>-ext-impl\src (into the SUB-project)
Now I wanted to deploy this and the problems starts:
Eclipse (Mars) does not allow me to drag and drop the root project (<project_name>), nor the sub-project where I added the file (<project_name>-impl).
The only one that I can drag and drop is <project_name>-ext. But if I do drag and drop this one and restart the liferay server, the ext does not work (it uses my normal portal-ext.properties and not the ext version).
Did I miss anything?
Also, am I supposed to see the portal-ext.properties in any of the jar / war files of any of the 9 sub-projects?
I do not see it in <project_name>-ext, nor in <project_name>-ext-impl
The Ext Plugin in a Maven structure is nothing you can drop into your server in the Liferay IDE - in place deployment is not supported here.
If you are a beginner - you should use the Plugin SDK (Ant).
If you really want to stick to the Maven then you will have to execute:
mvn package
in <project-name> and put the file <project-name>-ext\target\<project-name>-ext-x.x.x.war into LIFERAY_HOME/deployments and restart your Liferay server.
Disadvantage: For redeployment you will have to remove all deployed files and do the whole thing again. Up till now there is an Ant but not a Maven task for redeployment.
Finally you have dropped your portal-ext.properties at the wrong position. Maven is expecting resource files at /src/main/resources, so correct position is .../<project-name>/<project-name>-ext-impl/src/main/resources/portal-ext.properties.
And if the portal-ext.properties is the only reason for the Ext-Plugin: You can simply put that file into LIFERAY_HOME - no need for an Ext plugin here. And some properties are overridable in a Hook as well - which is easier to build and deploy, if you really want to create a package for modification here.
BTW: I'm using Maven for Ext Plugins as well - but in combination with some custom builders for hot deployment from Eclipse.
he fellas, i need your help again.
Im trying to develop a new part for an existing software. The parts are all done using Maven. I have to work in several projects at once, which are all continously opened in Eclipse. In Eclipse i use M2E, but i tend to edit the poms directly in xml.
So, now I can build (clean install) the projects individually, works ok. But Eclipse now has problems with the online help: It shows me errors. Eclipse cant seem to see classes which are placed in the same project, but different packages. Note that it works fine when i compile it!
Also after I run the pom the dependencies dont show up as "Maven Dependencies" but as "Referenced Libraries".
This persists after I run mvn eclipse:eclipse from outside and refresh.
Thanks so much for your help!
"Do not ever do mvn eclipse:eclipse", only do mvn eclipse:clean from command line first and then import "as maven projects" using your eclipse M2E plugin.
M2E Plugin knows how to handle Maven Dependencies, whereas mvn eclipse:eclipse knows how to handle Referenced Libraries, and they are NOT compatible with each other. You can always do mvn update project in Eclipse after mvn eclipse:clean.
I had to delete the maven-project, too, after using eclipse:eclipse. It added the references as "Referenced Libraries".
Manually deleting the .project and .settings files in the project folder and importing the project again helped. I used the M2E import. Afterwards it displayed the libraries within the "Maven Dependencies". Subsequently I was able to run it on my local webserver.
I do not really know the reason for the behavior, but deleting the project and reimporting it solved it.
I agree with kisna. As an alternative to fix the project if already contains both "Referenced Libraries" and "Maven Dependencies", you can do the following:
https://docs.oracle.com/cd/E14545_01/help/oracle.eclipse.tools.weblogic.doc/html/j2eelib/operations/opRemoveLibRefFromClasspath.html
Right-click on the project and select Properties -> Java Build Path -> Libraries tab -> Find the entry in the list of libraries called Shared Library [] or/and all libraries that starts with 'M2_REPO/', and then select it/them and remove.
I've got several projects in Eclipse (all are Maven projects) and one main project (also Maven project) which depends on the rest. I tried add this dependency by setting java build path (right click on project -> preferences -> java build path -> (tab) projects -> add). But there is a problem while executing maven install goal - this is compilation error: ... (class) ... "cannot be resolved" ... - this is definitely looks like maven does't see my resources from other projects. Eclipse is only warning me something like this: "Classpath entry /my-subproject1 will not be exported or published. Runtime ClassNotFoundExceptions may result." These warnings referenced to each subproject and occurs in main project. There is no error messages from Eclipse. In my main project, where I'm importing classes from subprojects, I can right-click on one of the import and choose "Open declaration" and there is valid reference to class from one of my subproject - so it looks like Eclipse sees my dependencies (there is no eclipse errors while building workspace - only these warnings mentioned above) from other projects, but maven doesn't see them while compilation.
Have you got any ideas how can I fix this?
Thanks for help.
You have to declare your dependencies in the pom.xml for Maven. Maven doesn't recognize any Eclipse specific configurations (like Build Path etc.): Maven Tutorial
If you use the m2eclipse plugin, it will configure your Eclipse build path according to your pom.xml configuration
Isn't this maven problem?
Maven needs jar file made from other project inside maven repository.
I don't know much about maven eclipse plugin but so far, in my observation, it seems like it works this way.
So that this case need to build other project so that create it's jar file.
But this takes so much time.
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.
I'm having maven project on Eclipse with m2eclipse plugin. This project has some dependencies. Some of them are libraries as slf4j, apache-commons etc. But there are also mine libraries, that I'm developing simultaneously in eclipse. Unfortunately m2eclipse creates build path in such a way that my libraries are added to the classpath not as a JAR archives from M2 repository but as class files from /target/classes directory. For that reason I can not use maven-shade-plugin beacuse I'm gettin a message:
" Error creating shaded jar: error in opening zip file /home/user/workspace/my-project/project-a/target/classes".
When I'm building project-a from command line using mvn clean install everything works well - shaded JAR is generated. How to fix it?
After few hours of searching I've already found solution. This can be made by configurinng Maven Build Configuration
1. Select arrow on Run as.. button
2. Select Run configurations...
3. Select yours project Maven Builder
4. On the right tab (Main tab) deselect: Resolve Workspace artifacts.
Click Apply and build your project - all will work as you wish :).