How to exclude the feature.source in tycho-source feature plugin configuration using regex? - tycho

While using the tycho-source-feature-plugin in pom.xml, the name of the feature with .source is given under excludes. Is it possible to use the regular expression which excludes all the features with .source instead of giving the feature.
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-source-feature-plugin</artifactId>
<version>${tycho-source-feature-plugin-Version}</version>
<executions>
<execution>
<id>source-feature</id>
<phase>package</phase>
<goals>
<goal>source-feature</goal>
</goals>
<configuration>
<excludes>
<feature id="myfeature.source" />
</excludes>
<labelSuffix></labelSuffix>
</configuration>
</execution>
</executions>
<configuration>
<labelSuffix></labelSuffix>
</configuration>
</plugin>

Related

How to resolve Inteliji Maven Configuration error for cucumberOutput?

There is an error in pom.xml with Inteliji, same pom.xml is working fine in Eclipse ,
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.6.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Automation</projectName>
<outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
<cucumberOutput>${project.build.directory}cucumber/cucumber.json</cucumberOutput>
</configuration>
</execution>
</executions>
</plugin>
Error is at <cucumberOutput>${project.build.directory}cucumber/cucumber.json</cucumberOutput>
Error message :
Element cucumberOutput is not allowed here
Version 5.6.0 no longer uses the <cucumberOutput> tag for the configuration.
It has been replaced with:
<inputDirectory>${project.build.directory}</inputDirectory> <!-- this is where the cucumber.json files is saved -->
<jsonFiles>
<param>cucumber.json</param> <!-- the name/regex of the cucumber report json file -->
</jsonFiles>
Here is an example of my configuration:
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.6.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>App-Under-Test</projectName>
<outputDirectory>${project.build.directory}</outputDirectory>
<inputDirectory>${project.build.directory}</inputDirectory>
<jsonFiles>
<param>cucumber-*.json</param>
</jsonFiles>
<mergeFeaturesById>false</mergeFeaturesById>
<mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
<checkBuildResult>false</checkBuildResult>
<buildNumber>1</buildNumber>
</configuration>
</execution>
</executions>
</plugin>

maven-replacer-plugin with multiple files

I am trying to use maven-replacer-plugin to replace values in several files.
First thing is I already read this topic and no answer work for me. I havn't enough point to comment and have neither the time nor the will to stupidly farm points on SOF. So, sorry for this duplicate but I need to step forward.
Back to the point, here is my pom
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.1</version><!-- already tried with 1.5.2 & 1.5.3 -->
<configuration>
<includes>
<include>${basedir}/target/mailtools.properties</include>
<include>${basedir}/target/digishop-config.properties</include>
</includes>
<replacements>
<replacement>
<token>$${dev.varA}</token>
<value>something</value>
</replacement>
<replacement>
<token>$${dev.varB}</token>
<value>somethingElse</value>
</replacement>
<replacement>
<token>${dev.</token>
<value>${</value>
</replacement>
</replacements>
<regex>false</regex>
</configuration>
</plugin>
mvn replacer:replace
[INFO] --- replacer:1.5.1:replace (default-cli) # digishop-a ---
[INFO] Replacement run on 0 file.
I tried the solution with
<filesToInclude>${basedir}/target/mailtools.properties,${basedir}/target/digishop-config.properties</filesToInclude>
and it didn't work either.
I manage to work around this issue by making multiple "single replacement" executions of the plugin
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>replace-xxx.properties</id>
<phase>install</phase>
<goals>
<goal>replace</goal>
</goals>
<inherited>false</inherited>
<configuration>
<file>target/xxx.properties</file>
<replacements>
<replacement>
<token>$${dev.mail.server.address}</token>
<value>xxx</value>
</replacement>
<replacement>
<token>$${dev.mail.server.port}</token>
<value>yyyy</value>
</replacement>
<replacement>
<token>${dev.</token>
<value>${</value>
</replacement>
</replacements>
<regex>false</regex>
</configuration>
</execution>
<execution>
<id>replace-zzz-config.properties</id>
<phase>install</phase>
<goals>
<goal>replace</goal>
</goals>
<inherited>false</inherited>
<configuration>
<file>target/zzz-config.properties</file>
<replacements>
<replacement>
<token>$${dev.hazelcast.client.group.name}</token>
<value>ttt</value>
</replacement>
<replacement>
<token>${dev.</token>
<value>${</value>
</replacement>
</replacements>
<regex>false</regex>
</configuration>
</execution>
<execution>
<id>replace-aaa-security.properties</id>
<phase>install</phase>
<goals>
<goal>replace</goal>
</goals>
<inherited>false</inherited>
<configuration>
<file>target/aaa-security.properties</file>
<replacements>
<replacement>
<token>${dev.</token>
<value>${</value>
</replacement>
</replacements>
<regex>false</regex>
</configuration>
</execution>
</executions>
</plugin>
Use basedir before add as much includes as you want, e.g.
<basedir>${basedir}/target</basedir>
<includes>
<include>mailtools.properties</include>
<include>digishop-config.properties</include>
</includes>

Share test resources between maven projects

There is a clear solution for sharing the common test code between maven projects using test-jar goal of maven-jar-plugin plugin (see here).
I need to do the similar thing with test resources, in particular, I want test resources of project A be available in the classpath of project B during testing.
For project A one need to declare:
<!-- Package and attach test resources to the list of artifacts: -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<jar destfile="${project.build.directory}/test-resources.jar">
<fileset dir="${project.basedir}/test-resources" />
</jar>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/test-resources.jar</file>
<type>jar</type>
<classifier>test-resources</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
And in project B it will be normal dependency:
<dependency>
<groupId>myproject.groupId</groupId>
<artifactId>myartifact</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>test-resources</classifier>
<scope>test</scope>
</dependency>
Question: Should it work in all cases? Is it possible to pack resources without maven-antrun-plugin (using more 'lightweight' plugin)?
Just use jar:test-jar and declare the resulting JAR as a dependency (refer to this guide for more details). And while I don't understand the problem of having resources and classes in this jar, you can always exclude all .class files:
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>**/*.class</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
And to use it:
<project>
...
<dependencies>
<dependency>
<groupId>com.myco.app</groupId>
<artifactId>foo</artifactId>
<version>1.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
...
</project>
Accepted answer helped me, but it's not quite accurate in case you need regular jar of same project as well. It will delete *.class files from both jars.
Settings below translates to something like:
create me 2 jars: 1 regular, 1 test;
remove *.class files, but only from test jar
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<excludes>
<exclude>**/*.class</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Using maven-dependency-plugin we can put the resource needed in the right directory, only modifying the pom on dependent project is needed:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>generate-test-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>dependeeGroupId</groupId>
<artifactId>dependeeArtifactId</artifactId>
<version>dependeeVersion</version>
<type>test-jar</type>
<outputDirectory>${project.build.directory}/test-classes</outputDirectory>
<includes>resourceNeeded.txt</includes>
<overWrite>true</overWrite>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
type is used to get test resource
outputDirectory is used to put the resource usable in tests
Documentation here: https://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html
There is already a goal to build a test jar from maven.
Assuming you need something a little more flexible, you can use the jar plugin to package your test resources and run that goal with the main package goal with something like this.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>test-resources</classifier>
<includes>
<include>**/*.whatever-you-want</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
Whatever you want bundled would be added to the project-name-version-test-resources.jar when the jar goal is run.
You could then include it in a project via the same dependency you use above.

The maven assembly plugin is not using the finalName for installing with attach=true?

I have configured following assembly:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>${project.name}-test-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${project.name}-test</finalName>
<filters>
<filter>src/assemble/test/distribution.properties</filter>
</filters>
<descriptors>
<descriptor>src/assemble/distribution.xml</descriptor>
</descriptors>
<attach>true</attach>
</configuration>
</execution>
<execution>
<id>${project.name}-prod-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${project.name}-prod</finalName>
<filters>
<filter>src/assemble/prod/distribution.properties</filter>
</filters>
<descriptors>
<descriptor>src/assemble/distribution.xml</descriptor>
</descriptors>
<attach>true</attach>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
This produced two zip-files:
distribution-prod.zip
distribution-test.zip
My expectation for the property attach=true is, that the two zip-files are installed with the name as given in property finalName.
But the result is, only one file is installed (attached) to the artifact.
The maven protocol is:
distrib-0.1-SNAPSHOT.zip
distrib-0.1-SNAPSHOT.zip
The plugin is using the artifact-id instead of property finalName!
Is this a bug?
The last installation is overwriting the first one.
What can i do to install this two files with different names?
Thanks for your investigation.
Roland
The last installation is overwriting the first one. What can i do to install this two files with different names?
As expected (I don't know if this is a bug or not but that's how the assembly plugin works). To avoid this, you will have to set the appendAssemblyId properties to true and, to obtain an equivalent result, to change the finalName to ${project.name} and the assemby id to test and prod (i.e. to use two assembly descriptors). Something like this:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>${project.name}-test-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<finalName>${project.name}</finalName>
<filters>
<filter>src/assemble/test/distribution.properties</filter>
</filters>
<descriptors>
<descriptor>src/assemble/distribution-test.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>${project.name}-prod-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<finalName>${project.name}</finalName>
<filters>
<filter>src/assemble/prod/distribution.properties</filter>
</filters>
<descriptors>
<descriptor>src/assemble/distribution-prod.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Where distribution-test.xml and distribution-prod.xml declare assembly id test and prod respectively.

Maven WAR plugin not reading configuration when running in <execution> tag

I'm trying to get Maven to perform several executions with the WAR plugin. It works fine as long as it's defined in the following way:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>1.0</version>
<configuration>
(...)
</configuration>
But not in the following manner
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
(...)
</configuration>
</execution>
</executions>
</plugin>
Where Maven can't find any of the resources I defined in the <configuration> tag. Have I missed anything important, and/or is there a better way of constructing multiple WAR files in a single build?
I didn't see how to turn off the war that's generated by default, but you can use one configuration outside the <executions> element and the rest inside:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<classifier>with-junk</classifier>
<!-- temp directory that the webapp is assembled in (each must be different) -->
<webappDirectory>${project.build.directory}/build-with-junk</webappDirectory>
<webResources>
<resource>
<directory>junk</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</webResources>
</configuration>
<executions>
<execution>
<id>add-other-junk</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<!-- exclude prior configuration -->
<inherited>false</inherited>
<configuration>
<classifier>with-other-junk</classifier>
<webappDirectory>${project.build.directory}/build-other-junk</webappDirectory>
<webResources>
<resource>
<directory>other-junk</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</webResources>
</configuration>
</execution>
</executions>
</plugin>
For me, this builds artifact-0.1-with-junk.war and artifact-0.1-with-other-junk.war and both have the correct files included.
The second version applies the configuration only to the phase you've specified. I'm not able to confirm this right now, but I'd guess it is not being applied because you haven't specified a goal for the configuration to be applied to.
If you add the war goal definition into the execution does it get applied? Like so:
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
(...)
</configuration>
</execution>
</executions>