Can't override POM property on the command line while executing release:perform - command-line

Given this complete Maven POM file that is meant to be used as a root POM for packaged (JAR, WAR, etc) projects or non packaged projects (for example web pages) that still should be tagged with a new release tag ...
<?xml version="1.0" encoding="ISO-8859-1"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Common Maven parent POM</name>
<description>Maven parent POM for common POM properties for any type of project</description>
<url>http://my.site.com</url>
<groupId>com.my.site</groupId>
<artifactId>mvn-common</artifactId>
<version>0.12-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<eclipse.projectName>${project.name} ${project.version}</eclipse.projectName>
<mvn.local.repo.root>file:///C:/.m2</mvn.local.repo.root>
<scm.url.root>https://localhost/svn</scm.url.root>
<scm.url.project>workspace/tools/maven/pom/mvn-common</scm.url.project>
<scm.url.trunk>scm:svn:${scm.url.root}/${scm.url.project}/trunk</scm.url.trunk>
<scm.url.tag>${scm.url.root}/${scm.url.project}/tags</scm.url.tag>
<!-- Deploy makes only sense to packaged artifacts -->
<skip.deploy>true</skip.deploy>
</properties>
<scm><developerConnection>${scm.url.trunk}</developerConnection></scm>
<distributionManagement>
<repository>
<id>mvn.repo.releases</id>
<url>${mvn.local.repo.root}/releases</url>
</repository>
<snapshotRepository>
<id>mvn.repo.snapshots</id>
<url>${mvn.local.repo.root}/snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<!-- These must also be defined in the local settings as <servers> -->
<repository>
<id>mvn.repo</id>
<url>${mvn.local.repo.root}/repo</url>
</repository>
<repository>
<id>mvn.repo.releases</id>
<url>${mvn.local.repo.root}/releases</url>
</repository>
<repository>
<id>mvn.repo.snapshots</id>
<url>${mvn.local.repo.root}/snapshots</url>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<skip>${skip.deploy}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<projectNameTemplate>${eclipse.projectName}</projectNameTemplate>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<tagBase>${scm.url.tag}</tagBase>
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>2.5</version>
</extension>
</extensions>
</build>
</project>
... can I not get the property true overridden on the command line when I execute
mvn release:prepare && mvn -Dskip.deploy=false release:perform
The property is used to set the configuration value for the maven-deploy-plugin to skip deploy as default (which should be overridden in a sub POM for packaged projects) and I believe that it should be possible to override a user defined property like this but not a Maven property which would be maven.deploy.skip in this case.
The release works fine in that it properly creates a new tagged version of the POM in the SVN repository but I can't get the maven-deploy-plugin to recognise the value for the property set on the command line
[INFO] [INFO] --- maven-deploy-plugin:2.8.1:deploy (default-deploy) # mvn-common ---
[INFO] [INFO] Skipping artifact deployment
[INFO] [INFO] ------------------------------------------------------------------------
Am I overlooking something here? A bug somewhere here could be an explanation but I have not found any reported that applies when I have searched around. It would be great if someone could see anything that looks incorrect or give me at tip on what to try next.

I eventually found the answer myself in Properties lost during Maven release:perform where the answer explained that there is a forked process for release so to get the command line property recognised and have it to override the property set in the POM must it be passed through as
-Darguments=-D...
and the command I must use then looks like this
mvn release:prepare && mvn release:perform -Darguments=-Dskip.deploy=false
Thanks to myself for answering this question and thanks Stephen Connolly that answered the other thread. It is just sad that I didn't find that answer until know in all the noise that come up when I try to google for it.

Related

Could not understand about Maven pom file using Eclipse

I am very new to Maven and i am creating my first maven project of maven-archetype-quickstart
Then it generates the error message ::
But in my project explorer :
I am unable to understand that why it is creating a proper maven project every time it shows a red warning mark into my project and as well as in my pom.xml file.
> pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.akash</groupId>
<artifactId>feind</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>feind</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- Change username in below line -->
<localRepository>/Users/COACH/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<offline>false</offline>
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups>
<proxies>
<!--
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>
<servers>
<!--
<server>
<id>deploymentRepo</id>
<username>crunchify</username>
<password>crunchify</password>
</server>
-->
</servers>
<mirrors>
<!--
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>mirror description</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors>
<profiles>
</profiles>
</settings>
I am fail to understand that why this happening every time to me and my .m2\repository folder is also empty . Please suggest me some steps to fix it and properly run a maven project.
Since i am not behind any proxy so i don't need to worry about the settings.xml file i just deleted .m2 folder and just simply try to create a maven project again
and maven itself downloads the required dependencies automatically.
Hence problem is resolved.
As reputable sources go:
apache/maven PR 38 illustrates you should not define any M2_HOME (not with recent maven versions)
apache-maven/src/bin/mvn shows that, if MAVEN_HOME is not defined, it defaults to where maven is installed.
By deleting your ~/.m2 folder, you have forced Eclipse (through m2e, included in any Eclipse 4.5 or newer), to revert back to a default m2 folder.
It also uses, per FAQ, the default <maven home>/conf/settings.xml

Maven local repo not updated with latest dependency

My project has a pom.xml which I did deploy to a remote repository inside my company
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ProjectMav</groupId>
<artifactId>ProjectMav</artifactId>
<version>1.0</version>
<distributionManagement>
<repository>
<id>man-release</id>
<name>mav release repo</name>
<url>http://xxxxxx.net/repositories/mav-release/</url>
</repository>
<snapshotRepository>
<id>mav-snapshots</id>
<name>mav snapshots repo</name>
<url>http://xxxxxx.net/repositories/mav-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
After I do a 'mvn deploy' I did browse the remote repository and I see the project there
I have another project that is dependent on the above mentioned 'ProjectMav' and it's POM.xml is as follows
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mavtest</groupId>
<artifactId>mavtest-suite</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>ProjectMav</groupId>
<artifactId>ProjectMav</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>mav-release</id>
<name>mav release repo</name>
<url>http://xxxxxx.net/repositories/mav-release/</url>
</repository>
</repositories>
<build>
<testSourceDirectory>src/com/mav/</testSourceDirectory>
<resources>
<resource>
<directory>/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Now from eclipse if I do a Maven>update project it does not get the latest version of my 'ProjectMav' to my local repository.
But if I clear all the files in my local repo and do a maven update it gets my project
Any idea what's going on?
I believe the issue is that the maven eclipse plugin's update doesn't actually do a mvn install which is what you need if you want to override the 1.0 deployed version. The way the mvn eclipse plugin orders classpath dependencies (which you can clearly see in the package explorer is to put the dependency jars first and then the resolved upstream projects after the jars). This seems to work fine for SNAPSHOT projects as the plugin knows to use your project and not the jars but for release jars it gets confused (or at least I have noticed it to).
That being said you should avoid this issue altogether by changing the version of your local one to:
<version>1.1-SNAPSHOT</version>
Then in your downstream projects that depend on ProjectMav you update their dependencies to 1.1-SNAPSHOT. The management of versions can be tricky so you might want to look into the maven release plugin and have it deal with version-ing of your project when you deploy.

Changing maven build output directory for .jar (has dependencies)

I'm setting up eclipse again to make plugins for bukkit, which is an API that i depend on. Also i want to move the .jar the build process creates to a directory of my choice.
http://wiki.bukkit.org/Plugin_Tutorial#Commands (makes the pom.xml below)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MY_PACKAGE_NAME</groupId>
<artifactId>MY_PLUGIN_NAME</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.7.9-R0.2</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Current output:
$project_root/target/MY_PLUGIN_NAME-0.0.1-SNAPSHOT.jar
Desired output:
C:/my/output/directory/MY_PLUGIN_NAME-0.0.1-SNAPSHOT.jar
You can use following configuration under <build> tag:
<outputDirectory>C:/my/output/directory</outputDirectory>
tip / warning : Although this will work but keeping your packaging outside target is discouraged. Its not maven standard. Rethink before doing it.

Error: Plugin execution not covered by lifecycle configuration maven error

I have a flex project that I need to convert into a maven project. I am using m2e for Eclipse and at the bottom of this post is the POM.xml file that I have created.
My issue is that I cannot seem to run a mvn clean install on this POM. In Eclipse there is an error highlighting the first "plugin" line that says:
-Plugin execution not covered by lifecycle configuration:
org.sonatype.flexmojos:flexmojos-maven-plugin:3.7.1:test-compile
(execution: default-test-compile, phase: test-compile)
and
-Plugin execution not covered by lifecycle configuration:
org.sonatype.flexmojos:flexmojos-maven-plugin:3.7.1:compile-swf
(execution: default-compile-swf, phase: compile)
Beyond that, if I do run the mvn clean install I get a different error:
Failed to execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:
3.7.1:compile-swf (default-compile-swf) on project flex: Failure to find
com.adobe.flex.framework:framework:rb.swc:en_US:3.2.0.3958 in
nexusserver/nexus/content/groups/public was cached in the local repository,
resolution will not be reattempted until the update interval of nexus has
elapsed or updates are forced
I am looking at the nexus server and I see:
-com\adobe\flex\framework\framework\3.2.0.3958
Inside there are a bunch of zips and stuff, and the file: framework-3.2.0.3958.rb.swc
So I'm not sure what actually the problem is. I'm still a bit of a maven novice and I've never actually used flex before so I think I am just a little overwhelmed at the moment. Does anyone have any ideas how to fix at least one of the issues? Thank you for your time.
edit: Even worse, the file is located in my local repository so I have no idea why it isn't seeing it.
--
POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated from the following command: mvn archetype:generate -DarchetypeRepository=http://repository.sonatype.org/content/groups/public
-DarchetypeGroupId=org.sonatype.flexmojos -DarchetypeArtifactId=flexmojos-archetypes-application
-DarchetypeVersion=3.7.1 -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.ref</groupId>
<artifactId>flex</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>swf</packaging>
<name>flex</name>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>3.7.1</version>
<extensions>true</extensions>
<configuration>
<locales>
<locale>en_US</locale>
</locales>
</configuration>
</plugin>
</plugins>
<sourceDirectory>src/main/flex</sourceDirectory>
<testSourceDirectory>src/test/flex</testSourceDirectory>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>test-compile</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>3.2.0.3958</version>
<type>pom</type>
</dependency>
</dependencies>
<profiles>
<profile><!--https://docs.sonatype.org/pages/viewpage.action?pageId=2949459 -->
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.maven.ide.eclipse</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>0.9.9-SNAPSHOT</version>
<configuration>
<mappingId>customizable</mappingId>
<configurators>
<configurator
id='org.maven.ide.eclipse.configuration.flex.configurator' />
</configurators>
<mojoExecutions>
<mojoExecution>org.apache.maven.plugins:maven-resources-plugin::</mojoExecution>
</mojoExecutions>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
This is the full error I get:
[INFO] Apache License - Version 2.0 (NO WARRANTY) - See COPYRIGHT file
[WARNING] Source file was not defined, flexmojos will guess one.
[WARNING] Not defined if locales should be merged or not
[WARNING] Unable to find license.jar on classpath. Check wiki for instructions about how to add it:
URL
Downloading: nexusURL/nexus/content/groups/public/com/adobe/flex/framework/framework/3.2.0.3958/framework-3.2.0.3958-en_US.rb.swc
[INFO] Unable to find resource 'com.adobe.flex.framework:framework:rb.swc:en_US:3.2.0.3958' in repository central (central)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to download the artifact from any repository
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.adobe.flex.framework -DartifactId=framework -Dversion=3.2.0.3958 -Dclassifier=en_US -Dpackaging=rb.swc -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.adobe.flex.framework -DartifactId=framework -Dversion=3.2.0.3958 -Dclassifier=en_US -Dpackaging=rb.swc -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
com.adobe.flex.framework:framework:rb.swc:3.2.0.3958
from the specified remote repositories: central
Update 3:This is my new POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.table</groupId>
<artifactId>flex</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>swf</packaging>
<name>flex</name>
<repositories>
<repository>
<id>flex-mojos-repository</id>
<url>https://repository.sonatype.org/content/groups/flexgroup</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>flex-mojos-repository</id>
<url>https://repository.sonatype.org/content/groups/flexgroup</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>3.7.1</version>
<extensions>true</extensions>
</plugin>
</plugins>
<sourceDirectory>src/main/flex</sourceDirectory>
<testSourceDirectory>src/test/flex</testSourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>3.2.0.3958</version>
<type>pom</type>
</dependency>
</dependencies>

How to add the plugin with my RCP application in the Tycho SWTBot test runtime

My RCP was created on a 3.x Eclipse and is now on 4.x using the compatibility layer.
This is the setup that I have: I have two plugins: xyz-plugin and xyz-rcp-plugin. My RCP application is composed of these two plugins. I have a Test fragment (xyz-test) whose host plugin is xyz-plugin and contains SWTBot tests. My product configuration points to the application defined in the plugin.xml of xyz-rcp-plugin.
When I run the SWTBot Test via Eclipse, it all works ok. I point it to the correct application on the Main tab and it launches the correct one.
When I try to run it via Maven (using mvn integration-test), after the command to launch the UI for testing, no UI opens and it just reports saying there are test failures but it never actually even reaches the stage for testing my cases.
I feel this is happening because my test fragment only has xyz-plugin as its host and so knows its dependency but the application is actually contained in xyz-rcp-plugin so I am guessing it doesn't bring that plugin into the testing workspace. In fact, the test runs when I omit the <application> configuration in my pom file; it simple launches the default which is the Eclipse SDK.
So but how can I make the SWTBot test run my application, if the plugin with the application is not a dependency of the test plugin?
Below is my pom file for the test fragment,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.xyz</groupId>
<artifactId>all</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.xyz.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<properties>
<ui.test.vmargs></ui.test.vmargs>
</properties>
<profiles>
<profile>
<id>macosx</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<ui.test.vmargs>-XstartOnFirstThread</ui.test.vmargs>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>true</useUIHarness>
<useUIThread>false</useUIThread>
<product>com.xyz.rcp.product</product>
<application>com.xyz.rcp.Application</application>
<argLine>${ui.test.vmargs}</argLine>
<dependencies>
<dependency>
<!-- explicit dependency is only needed because SWTbot brings its
own hamcrest bundle which conflicts with the one from junit in the eclipse
platform -->
<type>p2-installable-unit</type>
<artifactId>org.hamcrest</artifactId>
<version>0.0.0</version>
</dependency>
</dependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-xyz</id>
<phase>compile</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeTransitive>true</excludeTransitive>
<includeTypes>tar.gz</includeTypes>
<outputDirectory>${project.build.directory}/work</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Tycho does not automatically add the bundle defining the configured <application> to the test runtime - you need to manually ensure that this bundle is included.
One way to do this is to specify extra dependencies in the pom.xml of the test project. In this way, you can add bundles or even entire features (as always, including transitive dependencies) to the test runtime.
Example pom.xml snippet:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>xyz-rcp-plugin</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>