How to define 2 sets of profiles in pom.xml? - maven-3

I need to have a 2-dimensions profiles organisation in my pom.xml.
The project is about a fatclient app that comes in different flavours. Each flavour comes a slightly different set of dependencies, internalization files, splash screen, ...
This is one dimension of the profiles.
I also build the app for different os: windows, linux, mac.
This is the 2nd dimension of the profiles. And some stuff must change depending on the target (e.g. for windows, I build a ZIP file, while for linux and mac, I build a TAR.GZ file)
My approach for resolving this is by using the pom.xml profiles for the flavours, and to use the .m2/settings.xml profiles for the os target.
It works, but it isn't nice. Because the .m2/settings.xml should be limited to config specific to the user and not contain "build logic".
I'd like to "transfer" the "build logic" that I put .m2/settings.xml into the pom.xml.
But I don't want to have 1 Profile level having (#Flavours x #Os) profiles (e.g. flavour1-os1, flavour1-os2, ...)
Is this achievable ? Is there a way to implement this 2 levels of profiles in the pom.xml ?

Declare one profile for each flavour:
<profile>
<id>flav1</id>
...
</profile>
<profile>
<id>flav2</id>
...
</profile>
<profile>
<id>flav3</id>
...
</profile>
and one for each OS:
<profile>
<id>win</id>
...
</profile>
<profile>
<id>linux</id>
...
</profile>
<profile>
<id>mac</id>
...
</profile>
Activate them individually by e.g:
mvn -P flav1, linux ...

Related

cargo-maven2-plugin:start fails with "Actually there are no valid types registered for this configuration", regardless of what containerId I enter

I'm trying to run integration tests with the cargo-maven2-plugin and Tomcat 8. I want the Maven build to start the container for me, so I have configured the start and stop goals as documented here. The problem is that regardless of what I enter as containerId, the start goal always fails with a message saying that there are no registered configurations. The error messages always ends in
Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it?
I've tried various configurations, including ones that I found in various tutorials, and ones that user older Tomcat versions, but nothing helps. The error message is always the same.
Other posts here on Stack Overflow recommend to update the Cargo versions, but this doesn't apply to my problem: I already use the latest release version (1.6.5).
So, why do I keep getting this error?
For reference, here is one complete configuration that I tried out:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.5</version>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<artifactInstaller>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>8.5.23</version>
</artifactInstaller>
</container>
<configuration>
<type>standalone</type>
</configuration>
<deployables>
<!-- ... -->
</deployables>
</configuration>
</plugin>
The full error message for this configuration is:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.6.5:start (start-container) on project domain.db.itest: Execution start-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.6.5:start failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [tomcat8x], type = [installed]], configuration type [standalone]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [Help 1]
The solution was incredibly simple: I had the offline mode enabled. Without offline mode, Cargo downloaded the cargo-core-container-tomcat artifact, and apparently this artifact contains the definition of the tomcat8x configuration. Then, the container start was successful!
I had started the Maven build from Eclipse, so I didn't notice that the offline mode was enabled. I'm aware that this situation is quite special, but maybe someone else still benefits from my insight. It took me a while to solve, so I'm sharing problem and solution here. (After all, this is encouraged :-)
I got the key hint from a mailing list post, where thecargo-core-container-tomcat artifact was not downloaded due to a Nexus repository configuration.
This error is sometimes due to the cargo plugin version. Update your cargo plugin to the higher or latest version.
In my case, I updated from cargo 1.4.8 to cargo 1.7.0.
check this link,its may help:
click here

Jenkins:can not see test report tab

I can not see report tab here:
Public Junit test report:
I have configured Public JUnit test report, but I still can not see test report in left area.
As the OP joan.li adds in the comments, you need to make sure Your Jenkins installation knows about maven (as mentioned in "Jenkins executing maven from incorrect path"):
Add the default maven installation under (Jenkins -> configuration)
Goto the failing job and make sure you choose the default maven installation from dropdown
And You need to make sure your pom.xml does include a surefire build step
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
See also this example.
Check if those xml files are generated

Using Maven to build iOS

I am having issues with getting Maven to build out my iOS app. My plug in is set up like so:
<plugin>
<groupId>com.sap.prd.mobile.ios.mios</groupId>
<artifactId>xcode-maven-plugin</artifactId>
<version>1.14.0</version>
<extensions>true</extensions>
<configuration>
<settings>
<ARCHS>armv7 armv7s</ARCHS>
<ONLY_ACTIVE_ARCH>NO</ONLY_ACTIVE_ARCH>
</settings>
<sdks>
<sdk>iphonesimulator</sdk>
</sdks>
<configurations>
<configuration>Debug</configuration>
</configurations>
</configuration>
</plugin>
However, I'm getting the error:
The build has not been performed for default configuration 'Release' and default sdk 'iphoneos'
even though I'm trying to exclude Release by adding only the Debug configuration. What am I doing wrong here? I'd like to also build release, but I am trying to exclude it for now since it is giving me issues.
I've been stuck on this for about a month, sadly. So, any insight would be greatly appreciated.
Turns out there was a bug with version 1.14.0. Please update to version 1.14.1 of this xcode-maven-plugin to fix this issue.

maven-war-plugin overlay and m2e eclipse plugin

I'm trying to leverage the useful overlay feature of the maven-war-plugin.
In other words, I have a template (packaged as WAR file, template-0.0.1.war) containing tag files, css, js and images.
When I set template-0.0.1.war as a dependency of the myApp project I get a final myApp.war containing all the files of template-0.0.1.war overwritten by those with the same path in the myApp project.
This is the behavior I want.
However, I need to introduce in the pom.xml of myApp a configuration of the maven-war-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>../path/to/another/dir</directory>
</resource>
</webResources>
</configuration>
</plugin>
As soon as I introduce such a configuration of the plugin, I obtain the final myApp.war with all the files from both template-0.0.1.war and myApp project but the files of template-0.0.1.war overwrite those with the same path in the myApp project.
This behavior is exactly the opposite of what I expect.
Can someone tell me where I'm wrong?
Thanks in advance.
Edit after the solution was found:
The described issue is due to the concurrency of different actions: the WAR overlay (which works correctly) and the external webResources.
In fact, the external webResources tag points to the template project directory: totally unuseful for Maven, but indispensable to "fool" the m2e eclipse plugin and let it see the custom tags contained in the template.
The solution I have adopted is to introduce 2 different profiles in the plugin section of my pom.xml: the first one called "eclipse" in which I inserted the maven-war-plugin with the webResources and a second profile (called "standard" and activated by default) without the maven-war-plugin.
From the maven war plugin documentation:
By default, the source of the project (a.k.a the current build) is added first (e.g. before any overlay is applied). The current build is defined as a special overlay with no groupId, artifactId. If overlays need to be applied first, simply configure the current build after those overlays.
If you have files in the template that are being overwritten by files in the child WAR, you may want to consider explicitly excluding them in the overlay configuration.
Here's what the documentation says to apply the overlay first:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<overlays>
<overlay>
<groupId>com.example.projects</groupId>
<artifactId>my-webapp</artifactId>
</overlay>
<overlay>
<!-- empty groupId/artifactId represents the current build -->
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>

How can I create a rpm that includes rpm modules with maven?

I am trying to generate a "rpm container" with rpm-maven-plugin. This container should include three rpm I have generated before and shared in a yum repository. So the idea is to have an empty project with a pom file that generates a rpm file, which contains just three rpms that come from the repository. My problem is that I do not want to include anything else, so I do not need to map anything in there because the rpms inside they have their own mapping configuration and postinstall scripts. I add a small example to explain my question better.
I have in a local yum repository (aaa.repo) three projects proj1.rpm, proj2.rpm, proj3.rpm.
I have created a new project with a lonely pom.xml with rpm-plugin to make a "global" rpm which contains these three projects, what I have done so far is this:
< plugin>
< groupId>org.codehaus.mojo< /groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.1-alpha-2</version>
<inherited>false</inherited>
<executions>
...
</executions>
<configuration>
...
<provides>
<provide>dump</provide>
</provides>
<requires>
<require>proj1</require>
<require>proj2</require>
<require>proj3</require>
</requires>
<mappings>
<mapping>
<directory>/usr/local/globalProject</directory>
</mapping>
</mappings>
</configuration>
</plugin>
I had to add an empty mapping because it does not run without it.
When I execute:
sudo yum -v --nogpgcheck localinstall globalProject.noarch.rpm
It resolves the dependencies but it does not install the content of the rpms.
Any ideas?

Resources