update code and reflect the changes in AEM CQ5 - aem

How to see instantly update the code and see that it is reflected without firing up Maven Clean Install again and again in AEM CQ5 project? I know it can be possible through JRebel in normal Java projects. But I am not sure in AEM Projects.

As mentioned by jiggy, code changes in /apps(component jsps ..), /etc (css, js..), etc can be synced with AEM using vault plugin. This does not require rebuild/package/deploy to AEM using 'mvn clean install'.
Server side(java files) changes however requires firing up 'maven clean install' and installing the new generated bundle either manually or automatically via profiles in maven POM to AEM.

You can sync repository items with vault. One at a time or with vault sync. There vault plugins available for both Eclipse and IntelliJ.

Related

Alfresco configurations

Is there a way to automatically refresh the changes I made in my java classes once I ran my alfresco repository in eclipse ?
Because it is very time consuming to stop my tomcat, make changes in my classes and re run it then test the changes I made.
Is there a way to configure it ?
Yes there is way, If you are using SDK 3.0 you need to configura hotswap agent.
Below link will help you in that.
https://docs.alfresco.com/community/tasks/sdk-hot-reload-hotswap.html
You can configure hotswap agent in eclipse also.same add same configuration in eclipse (Run Configuration->Maven Build->New Build)
add goals as clean install alfresco:run
In jre tab add this configuration In VM arguments field ==> -javaagent:[path]hotswap-agent.jar
Run it.
In case of SDK 2.0 you need to use spring-loaded jar instead of hotswap agent.Configuration steps are almost same except the goals.

How to deploy hybris with storefront addon

We are using the b2bacceleratoraddon and commerceorgaddon addons in our hybris 6.5.0.1.
For the local development it is enough to run the ant addoninstall command.
But what is the official way to integrate these addons in a deployment process? We tried to check-in the generated sources in the repository but that does not seem to work.
We don't want to manually install the plugin after every deployment.
Also, as we are doing our deployments with ydeploy, is there a way to integrate this in the ydeploy process?
The ant addoninstall task is meant to be executed only once. It manipulates some files die the addon to work correctly. These files are:
myaddon/project.properties
mystorefront/extensioninfo.xml
The first file is created with properties that register the addons JavaScript and CSS sources as well as a property which includes the addons spring web context in the storefronts web context.
In the second file it created a dependency from the storefront to the addon. That way during startup spring beans of the addon are created before the storefront beans are created. Also during build, hybris copies the addons web sources into designated folders in the storefront extension.
So as long as you deploy these files along with the other files, you can skip the addoninstall task.
You have a file called localextensions.xml inside the hybris config folder where you can select the extensions that your project will use.

How to use multiple alfresco AMP file in eclipse

I have created one Alfresco project in Eclipse. I want to use one uploader-plus AMP file in my newly created Alfresco project in Eclipse.
How can I achieve this?
can we use multiple amps in single alfresco project in eclipse or can we create single amp file by combining 2 different amp files???
Independently from the IDE you are using, it is possible to setup an All-In-One project to fetch and apply several extra amps before starting up (either from a local or a remote maven repo) :
Create a new amp (Optional)
Build a release for your amp (Optional)
Add dependency for your amp in your project (You may need to add a repository as well)
Add an overlay for your amp to either share or repo (depending on the nature of your amp)
Run and enjoy
To learn more about this process please check the official documentation here
UPDATE : In the case of uploader-plus amps, you need either to fetch projects from here and install them locally (using mvn clean install) or add reference in your pom to this maven repo :
https://oss.sonatype.org/content/repositories/releases/ but I can see only v1.2 is released there so you probably would want to stick to option 1 !

Tycho and Eclipse: How to resolve OSGI dependencies to my own bundles at development time within Eclipse, without opening all of them in the IDE

Background
My Eclipse RCP application is built using Tycho. It consists of multiple components (in the form of OSGi bundles/Eclipse plug-ins). One of these component contains the product file and materializes the product.
There is a reactor POM at the application root, which builds all components in order, but I also want to build other components independently (using mvn deploy) .
Building such a single component works as follows:
Retrieve the latest versions of all the component's dependencies from our company (p2) repository.
Build the component.
Deploy the component to our company repository to be used as a dependency for other components itself.
Note: Our repository is a normal maven2 repository hosted on a Nexus, whose RCP artifacts are automatically mapped to a p2 repository format as well. This way, Tycho can use the p2 repository format to find dependencies, while the standard Maven deployment can be used. This works fine.
Note: My parent POM makes sure that we look for dependencies at the p2 repository URL. The deployment URL is the default maven2 format location of the repository. This works fine.
Problem
When building such a single component through the command-line (mvn deploy), Maven looks for intra-project dependencies in the p2 repository and they are correctly resolved (i.e. latest version is automatically downloaded and used in build).
However, when developing in Eclipse, the IDE cannot resolve them. The manifest files gives an error at each of my intra-project dependencies that they cannot be resolved.
Question
My question is: How can I make the Eclipse IDE look for dependencies (and new versions of dependencies) in either:
My local p2 repository (~/.m2/repository/p2/osgi/bundles)
My company p2 repository (nexus.mycompany.com/myproduct-snapshots/.meta/p2)
Ideally, it would look for them every time and fetch the latest version if a newer version is available.
If it does not use the p2 repository URLs in the POM, how should I configure Eclipse?
Example
Consider an eclipse plug-in com.mycompany.myproduct.fancy, which depends on another eclipse plug-in com.mycompany.myproduct.core.
Both also have a POM (configured for Tycho use), which (through their parent POM) have my Nexus repositories configured correctly: maven2 repository URL for deployment and p2 repository URL to look for dependencies.
First I deploy the core plug-in to my maven repository (using the default mvn deploy). The Nexus repository will provide this deployed plug-in in both maven and p2 format.
When I build the fancy component through the command line (using mvn install), the (earlier deployed) core component is found and downloaded automatically.
project/com.mycompany.myproduct.fancy$ mvn clean install
<searches in p2 repository, download core>
<builds fancy>
<SUCCESS>
When I open a new Eclipse workspace and open the fancy component, its Manifest (which contains its dependencies) gives the following error:
Bundle 'com.mycompany.myproduct.core' cannot be resolved.
My question is: how can I develop the fancy component in the Eclipse IDE without the need to open core as project in Eclipse.
Speculation
This is some speculation from my side. Please correct me if I'm wrong and any other solution to the actual problem is also welcome!
I know the m2e plug-in of the Eclipse IDE currently maps Maven POMs to Eclipse concepts (using m2e connectors). I have installed the dedicated Tycho connectors. For example, the mvn compile step is actually performed by the Eclipse JDT compiler.
I also know that when a complete Tycho product is started in Eclipse, it is run in the Eclipse PDE environment. For example, I need to a specify a target platform in my Run configuration.
I know I can open all components in my Eclipse workspace. This would solve the problem, but is not feasible as I have many components and this would break independent component development.
I assume the Eclipse m2e mapping and/or the PDE build environment is not smart enough to fetch (latest) dependencies automatically at build time. Please correct me if I'm wrong. :)
Therefore, I assume I need to specify the target platform at build time too. I have taken a look at Window > Preferences > Plug-in Development > Target Platform. I can add our p2 repository to the Target Platform, which solves the problem. However this gives many problems:
I need a feature containing all components for this to work. Only features can be added.
Every time I deploy a new build of a single component, I would have to rebuild the complete feature (to create a new feature version on our p2 repository).
Every time I update a component and build the feature, I would have to manually change the Target Platform.
If the above is all correct, I speculate I need an m2e connector (or a different one from the current one) that actually checks the p2 repositories specified in the POM when resolving the OSGi dependencies and automatically adds those to the target platform.
As indicated by Nick Wilson, you will need to install the m2e Tycho Configurator, which basically "links up" Eclipse and Tycho (i.e., makes Tycho available in Eclipse).
You should've been pointed towards it after having installed m2e, but you can also install it manually:
Go to Window > Preferences > Maven > Discovery.
Click the "Open Catalog" button. This will open the "m2e Marketplace" window.
Search for "tycho", this should give you the "Tycho Configurator" as sole search result.
Click "Finish", you're done.
I've had this issue as well, and it isn't simple to find the solution, so I hope this helps!
The "most automated" way to configure your target platform in Eclipse is to use a target file. That file can be checked in with your sources, so every developer only needs to open the file and click on "Set as Target Platform" to activate it. AFAIK there is no m2e connector or Eclipse plug-in which does that automatically.
Given your development process, setting up this target file is a little more tricky. Since you don't have a feature which contains the latest version of all your bundles, you need to include the bundles directly in the target file. This is not possible via the rich editor, but can be done with a text editor:
Create a target definition file, add your p2 repository, and select any feature from that p2 repository. Save the file.
Open the target file in a text editor, remove the <unit> entry for the feature you added.
Instead, add an entry for each of your bundles:
<unit id="a.bundle.symbolic.name" version="0.0.0"/>
This target file then contains the latest version of each of the listed bundles. To see the content, open the file with the "Target Editor" again and switch to the "Content" tab. This file can now be used by all developers.
Note: When a new version of one of the bundles is deployed to Nexus, the developers will only see that new version if they open the target file and choose "Set as Target Platform" again.

How to deploy generated resources to tomcat with m2e-wtp?

I am pulling JavaScript from a jar as part of my build process. I wish this js to be part of my web resources for the app deployed on tomcat and I have updated my build process to allow this to happen. Doing a maven build (outside eclipse) works as expected and I can package up a war with everything in its proper order.
However, when building with eclipse I have run into some headaches. My understanding was in order to have web resources deployed to tomcat through an incremental build, I needed to put these build-time generated js files into the target/m2e-wtp/web-resources directory. However, when I publish these new files are ignored and the web-resources deployed to tomcat seem to be pulled from my source.
I also adjusted my project's deployment assembly settings. Through this I still don't have it working. I have the entry [source:/target/m2e-wtp/web-resources, DeployPath:/] which should find the newly generated files when I perform a "publish" to the server. However, the same thing happens where m2e-wtp seems to be pulling from source.
Am I missing something? How can I get standard behavior from m2e-wtp (i.e. make it comparable to a build done outside of eclipse)? Or can I have eclipse just build the war and deploy it as such (not do the incremental builds, I can sacrifice some speed)?
FYI (versions):
eclipse: (Using Spring Tool Suite) 3.2.0
m2e: 1.3.1
m2e-wtp: 0.17.0
tomcat: 7.0
Experiment added later:
After deleting my target dir, I performed a publish to Tomcat and all the web-resources were copied from my source. I also got a popup about files not found, most of which are compiled classes. However, it was looking for three files in the /target/m2e-wtp/web-resources/META-INF. Does the m2e-wtp plugin only look for specific files in a folder rather than the entire specified folder?
The problem is that the target directory was not being refreshed. Eclipse (or m2e plugin for that matter) doesn't recognize or care that files change in the target directory during a build, something that I was assuming. For now I have the auto-refresh (for the workspace) option on. The refresh on access option didn't working as it seemed to trigger the refresh only when I was publishing to tomcat for the first time.