How to redeploy artifact with liberty-maven-plugin? - deployment

I have IBM Liberty server running on my machine and want to redeploy my WAR using corresponding maven plugin.
The documentation says that there are goals like deploy , undeploy , install-apps . Currently I am using
<plugin>
<groupId>com.ibm.websphere.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>install-apps</id>
<phase>install</phase>
<goals>
<goal>install-apps</goal>
</goals>
</execution>
</executions>
<configuration>
<serverHome>c:/my-liberty-instance</serverHome>
<serverName>myServerName</serverName>
</configuration>
</plugin>
But it's not good for me because it requires the server instance to be stopped before. If it's running - a new WAR is deployed (it replaces the old one) but no new changes are caught up.
I've tried to use deploy goal but once it copies WAR to the dropins directory - it starts searching some console.log file for some line that should indicate if app is started and FAILS.
Example for undeploy goal : CWWKM2022E: Failed to undeploy application app-1.0-SNAPSHOT.war. The Stop application message cannot be found in console.log.
But the same message appears for deploy , stop-server .
Is there a convenient way to redeploy WAR using liberty-maven-plugin where I don't need to restart the server ?
I just want to build a new WAR - deploy it; want the server to catch up the changes and that's it.

You can use the install-apps goal to install the project war file without your liberty server instance stopped. But you need to use liberty-maven-plugin version 1.3 or above, and also include <installAppPackages>project</installAppPackages> to the plugin configuration.
<plugin>
<groupId>net.wasdev.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>install-apps</id>
<phase>install</phase>
<goals>
<goal>install-apps</goal>
</goals>
</execution>
</executions>
<configuration>
<installDirectory>c:/my-liberty-instance</installDirectory>
<serverName>myServerName</serverName>
<installAppPackages>project</installAppPackages>
</configuration>
</plugin>

Related

Mavan deploy goal rewrites even the unmodified files in the repository

I am assigned to implement an incremental deploy of a multimodule maven( Maven 3.5.3) project. Whenever I am trying to deploy the project using "deploy -DaltDeploymentRepository=internal.repo::default::file:///home/Example", from eclipse IDE even the unmodified jars and pom are also getting replaced with new ones. Which is not considered as a incremental deploy. Is there any way to only upload the modified jars to the local repository home/Example.(I am using TFS for CI but after the testing the application is physically distributed to customers.)
I tried takari plug-in to do that but its only effective for compile/jar/testCompile goals.I can't see any incremental install or deploy.
I can't use deploy: file list, its not an automated process.
<plugin>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-lifecycle-plugin</artifactId>
<version>1.13.10</version>
<configuration>
<proc>proc</proc>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>deploy</id>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
I can see incremental build in compile phase but not in deploy. Anyone have a solution to do the incremental deployment using any plug-ins or anything?
I tried takari plug-in to do that but its only effective for compile/jar/testCompile goals. I can't see any incremental install or deploy.

How to launch browser automatically after war deployment?

I have a war maven project and I want that when I deploy it on the server the default browser (Mozilla in my case) is launched automatically with the default url for access to the main page.
Of course with JBoss EAP6 I have just to run the Maven command clean install jboss-as:deploy to generate the war file and deploy it on the server.
Do I have to add something to the pom.xml or make any configurations in Eclipse?
Use maven's exec plug-in. More information here.
I used this and it works good but juste for the maven phase : install but for the deploy no:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>Run URL in system browser.</id>
<phase>install</phase>
<configuration>
<target>
<exec executable="start" vmlauncher="false">
<arg line="http://localhost:8080/mywarApp" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
I use eclipse and i made for goals "clean install jboss-as:deploy" into the run configurations. and when in click in , once the install phase is runing the browser is runing too but i want that it will happen when the deploy phase is end of runing , have you any idea

maven goals, compiling and deploying to a server

I'm using eclipse to manage a maven project.
In the pom of this project I have a special plugin, which create a file during the generate-ressources phase :
<plugin>
<groupId>org.eclipse.acceleo</groupId>
<artifactId>maven</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>acceleo-compile</goal>
</goals>
</execution>
</executions>
</plugin>
I have linked this plugin goal to eclipse lifecycle to execute it during eclipse compilation :
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.eclipse.acceleo</groupId>
<artifactId>maven</artifactId>
<versionRange>[3.2.1,)</versionRange>
<goals>
<goal>acceleo-compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
When I do a clean project with eclipse, the project compile again and the file is well generated during the eclipse compilation (I can find it in the target directory).
Now, I want to deploy my webapp on a tomcat server. I create a tomcat server using the server view of eclipse and I drag and drop the project into this server to synchronize and publish it.
The project is well deployed and I can launch the server and test my app.
BUT, the file which needs to be generated by the maven plugin is not copied during the publish operation...
So my question is : why the file generated by a maven plugin is well generated during the eclipse compilation but is not deployed on the server during the publish/synchronize operation of the automatic server management by eclipse ?
The answer is in your question, cause you configured the plugin to run only during the eclipse Life cylce, but you've missed to add the exection to your build life cycle.
As far as I know the publishing of your webapp is done by eclipse wtp tools.
To configure this (what gets deployed to the server) check out this question and the according answers.
In short: I think you need to configure that the generated file (from your target dir) is also copied when wtp deploys your app.

How to copy dependencies to gae war/WEB-INF/lib

I'm coming from Ant perspective, so pardon me. I realise there are quite a few questions here already on how to maven dependencies, but none of them seem to tell how to do what need to do.
Question 1:
Currently, in conjunction with using maven-war-plugin, when I run mvn war:war, it creates a war folder in target folder.
However, I wish copy all the dependencies' jars to war/WEB-INF/lib set up by google eclipse plugin (with gae enabled, gwt disabled), without overwriting the jars that google eclipse plugin placed there.
I don't wish to setup a war file or war directory. I just need to copy/consolidate all the non-gae jars with the gae jars so that when the project is run as a gae web app, Eclipse would not complain ClassNotFoundException.
Question 2:
When using Ant in Eclipse, I could run Ant targets within Eclipse.
Right now, I have to perform mvn commands from a shell window (which is mutually oblivious to the existence of an Eclipse session). It appears that the only thing that is automatically done is whenever I update dependencies.
Is there a way, or any plugin for eclipse that would allow me to run mvn goals within Eclipse?
Additional info:
mvn dependency:copy-dependencies persists in copying to target/dependency directory, with the following:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>process-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/war/WEB-INF/lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeArtifactIds>gwt-user,gwt-dev</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
I even tried changing to absolute path
<outputDirectory>
/home/geek/eclipse/workspace/Demo-autoshoppe/holycow
</outputDirectory>
But holycow directory is still empty and mvn still persists in copying to target/dependency directory. My current solution is to softlink target/dependency as war/WEB-INF/lib, which is a very very bad kludge. Why is maven not sensitive to outputDirectory specification? I am using Ubuntu's maven 2.2.
I have the real answer for you, my man.
Use the "default-cli" execution id. Make sure you're using Maven 2.2+. This exec-id applies to command-line executions of the mojo.
<build>
<pluginManagement>
<plugins>
<!-- Copy dependencies to war/WEB-INF/lib for GAE proj compliance. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/war/WEB-INF/lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeArtifactIds>gwt-user,gwt-dev</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Cheers.
An associate emailed me this answer which works. Trigger the follow through
mvn build or mvn package
but not directly thro mvn dependency:copy-dependencies.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/war/WEB-INF/lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeArtifactIds>gwt-user,gwt-dev</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
Regarding #1: I'd suggest creating your maven project based off this plugin and archetype http://code.google.com/p/maven-gae-plugin/ (see the GWT based example if you are writing a GWT app for GAE).
Regarding #2: Check out m2eclipse plugin for full maven integration in eclipse. It's written by Sonatype (the creators of maven): http://m2eclipse.sonatype.org/

How to setup bundle development environment (Eclipse Equinox Maven)

I'am trying to setup eclipse environment to develop bundles (With maven-bundle-plugin-bnd)
and run & debug that bundles equinox from eclipse
I created sample bundles with org.apache.felix maven-bundle-plugin and can install and start that bundles from eclipse equinox,
but every time i need to run "install file:C:\path\bundle1.jar","install file:C:\path\bundle2.jar" which causes pain. i searched for run configuration but it only intalls and starts (plugin) projects in workspace not maven projects.
What i have done is create maven project and add dependencies(bundle1,bundle2 etc..) and added maven-dependency-plugin to copy all depended bundles in one folder (another problem is equinox use "_" delimeter to determine version of bundles but maven uses "-" as delimeter) if i do not strip version in standalone equinox application i need to give version of bundle in config.ini file but i dont want that, is this proper way to solve this problem?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${bundleDirectory}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<stripVersion>true</stripVersion>
</configuration>
</execution>
</executions>
</plugin>
To sum up , i have bundles in folder, which is created with org.apache.felix maven-bundle-plugin , how can i run and debug them from eclipse?
I wouldn't say this is a "proper" solution, but it may work for you.
The antrun plugin can be used to modify the dependencies to replace the final hyphen with an underscore, so the dependency plugin doesn't need to strip the version.
My regex is rusty, but from a little testing the following configuration appears to apply the required name change to the files in the bundleDependency directory.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${bundleDirectory}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<!-- move within same directory is preferred method for a rename-->
<move todir="${bundleDirectory}">
<fileset dir="${bundleDirectory}"/>
<mapper type="regexp" from="([a-zA-Z0-9\.-]+)(-)([0-9\.]+.jar)"
to="\1_\3"/>
</move>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
</plugin>
I wrote a tool called auto-builder (http://code.google.com/p/auto-builder). It introspects PDE-based projects and generates Ant build files; it supports transitive closure over dependencies and all that jazz.
I posted a write-up: http://empty-set.net/?p=9. I wrote it because the Maven tools I played with, when integrated with PDE, didn’t “just work.” Basically, I wanted to do coding in PDE and have a Hudson-based CI without any fuss in between.
Generating Ant files is nice because it gives you all the benefits of a declarative build tool, but it leaves you with a procedural description of what it is doing.
I am looking for more PDE-based projects to test it on. There are a couple RFC-0112 Bundle repositories around, and I have some code for downloading dependencies. If anyone is interested, then I could integrate dependencies download with auto-builder.