issue to deploy a Maven built Ext using eclipse - eclipse

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.

Related

class test in an existing project j2ee converted to maven project

I'm a beginner in Maven and i have to "mavenize" an existing project for a company.
I opened the project in Eclipse and right click on the project -> Configure -> Convert to Maven Project.
So after that I didn't get the folders : src/main/java, src/main/resources, src/test/java, src/test/resources. I didn't get anything.
I have the m2e plugin and also Maven 3.3.3
I get the lib and Maven Dependency and arrange the pom.xml but i didn't have any test folder and any class Test so when running mvn:test i get no tests to run.
My question is : I have to create all the classTest manually ? Or Maven is supposed to create them automatically ?
Convert to Maven would normally:
configure the Maven Compile Plugin according to the JDK version in use by the original project
configure the build/sourceDirectory element (normally to src) instead of the standard src/main/java
ignore the bin folder used by default by Eclipse (so may see it in the Package Explorer and you can safely delete it)
Some manual steps are required (and suggested):
move the code to a newly created src/main/java folder and remove the build/sourceDirectory customization
remove the bin directory (it will now be target/classes)
Create src/main/resources folder and move any required resource (configuration file, etc.) to this folder
place your test sources under src/test/java, which you also need to create
if not the case, rename any test class to end by the *Test or *TestCase suffix so that by default the Maven Surefire Plugin will pick them up automatically (if not possible, alternatively you would need to configure it as described via official documentation here
If you don't have any test class yet, of course Maven would never create them automatically, you are responsible of writing your test cases, Maven would only run them.

Making Eclipse Maven repository inside the project

I'm a real beginner to Maven and Spring framework in eclipse so excuse me if this sounds trivial..
I have created a MVC web project in eclipse using the STS plugin on my windows computer, but my problem is that the location of the jar and configuration files that maven is set to by default is: C:\Users\MyName.m2\repository
This is a problem for me because eventually I'm going to make a WAR file out of my project and deploy it on a Linux machine, which does not have Maven installed on it.
My question is, is it possible to take all the jar files in my Maven repository, and make a local repository on the project itself rather than on an absolute path on the machine (sort of like a lib folder within the WEB-INF in the project that will hold all the maven jars and that maven will direct itself to it), and thus making the transition to the Linux machine smooth
I understand there is this classpath variable named M2_REPO, but doesn't seem to be editable or accept relative path rather than absolute.
Thanks in advance
Since you are using maven and you are adding your dependencies on your pom.xml, then all the dependencies with a scope of "compile" will be added to your final war file created by the maven war plugin under the WEB-INF/lib folder, this means that you should not worried about having maven in your linux server, since the war file that you are going to deploy will contain all the necessary dependencies. If you want to confirm this, just create a package of your project using "mvn clean package" and check the "target" folder generated by maven, you will see a "war" file, and you can unzip your file to check what contains.

Why maven is not working in eclipse indigo?

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

How to integrate maven 2 in an existing netbeans project?

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.

m2eclipse : Maven dependencies as JAR's not projects

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 :).