Mavan deploy goal rewrites even the unmodified files in the repository - eclipse

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.

Related

How to redeploy artifact with liberty-maven-plugin?

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>

How to generate second EAR with sources

I have a project that consist of multiple modules (ejb's, jar's, war's) and I'm using a pom.xml of type "ear" to package them. It works perfectly fine and it generates an EAR-file with the correct jar's / etc.
What I additionally need is a second EAR-file with source code of included modules... I tried to use the source plugin as follow but the generated EAR didn't include any sources:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
Funnily enough when I run "install" on my parent pom.xml, where all modules are included, the %MODULE_NAME%-sources.jar files are generated in my local maven repository. Is it possible to somehow reuse them and package into a second EAR?

Skip Maven Flex PMD

We are looking for an option in flex-pmd-maven-plugin to skip the pmd execution temporarily using a command-line option. The maven pmd plugin has a -Dpmd.skip=true option.
I am looking for a similar kind of thing for flex-pmd-maven-plugin too.
<plugin>
<groupId>com.adobe.ac</groupId>
<artifactId>flex-pmd-maven-plugin</artifactId>
<version>${flex-pmd.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<ruleSet>build_rules/Flexpmd.xml</ruleSet>
<excludePackage>**/Mocked*.as</excludePackage>
</configuration>
</plugin>
I had a look at the source code for the plugin and there seems to be no option to do that.
Any ideas or a work around on this is welcome..
I found a workaround to skipping the Flex PMD without having to actually remove the plugin.
The flex-pmd plugin runs in the verify maven phase. I got the phase in the plugin parameterized as and passed a command line argument -Dpmd.phase as either deploy or package.
An then I then ran the command
mvn clean install -Dpmd.phase=deploy
Since maven runs only until install phase and the pmd phase is changed to deploy, the Flex PMD is skipped.. :)
When I want to run the Flex PMD, I just change the hudson build to run the following
mvn clean install -Dpmd.phase=package
Here the code snippet
<plugin>
<groupId>com.adobe.ac</groupId>
<artifactId>flex-pmd-maven-plugin</artifactId>
<version>${flex-pmd.version}</version>
<executions>
<execution>
<phase>${pmd.phase}</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<ruleSet>build_rules/Flexpmd.xml</ruleSet>
<excludePackage>**/Mocked*.as</excludePackage>
</configuration>
</plugin>
I have also the following default property in the pom so that pmd will run by default for developers who run the normal mvn clean install
<properties>
<pmd.phase>package</pmd.phase>
</properties>

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.