Don't Generate Windows Sections Using Appassembler - maven

I am only targeting Solaris when using Appassembler and have this in my 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow</groupId>
<artifactId>question</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>generate-jsw-scripts</id>
<phase>package</phase>
<goals>
<goal>generate-daemons</goal>
</goals>
</execution>
</executions>
<configuration>
<repositoryLayout>flat</repositoryLayout>
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<target>${project.build.directory}</target>
<configurationDirectory>conf</configurationDirectory>
<daemons>
<daemon>
<id>${project.artifactId}</id>
<mainClass>org.apache.catalina.startup.Bootstrap</mainClass>
<jvmSettings>
<initialMemorySize>512</initialMemorySize>
<maxMemorySize>1024</maxMemorySize>
<extraArguments>
<extraArgument>-Dapp=${project.artifactId}</extraArgument>
<extraArgument>-XX:MaxPermSize=128m</extraArgument>
<extraArgument>-XX:+UseParNewGC</extraArgument>
<extraArgument>-XX:+CMSParallelRemarkEnabled</extraArgument>
<extraArgument>-XX:+UseConcMarkSweepGC</extraArgument>
</extraArguments>
</jvmSettings>
<platforms>
<platform>jsw</platform>
</platforms>
<generatorConfigurations>
<generatorConfiguration>
<generator>jsw</generator>
<includes>
<include>solaris-x86-32</include>
</includes>
<configuration>
<!--Logging-->
<property>
<name>wrapper.logfile.maxsize</name>
<value>10m</value>
</property>
<property>
<name>wrapper.logfile.maxfiles</name>
<value>10</value>
</property>
</configuration>
</generatorConfiguration>
</generatorConfigurations>
</daemon>
</daemons>
</configuration>
</plugin>
</plugins>
</build>
</project>
However, a bat file is still generated and there is a Windows specific section in the generated conf.
Neither are going to stop me running - for instance I can exclude the bat file when using the assembly plugin and I don't think the Windows section will affect me on Solaris.
However, for neatness sake I would rather not generate either in the first place.
Is there a way to prevent them being generated?
EDIT: Added full example pom
EDIT2: I think this is a bug so opened an issue here

Related

Properties defined in the properties section of the POM are not seen in external ant build file

I'm using maven-antrun-plugin in my pom.xml with external ant file.
It's said in plugin's document:
All of the properties available to Maven are also available in the
target configuration. However, you may want to call an external Ant
build script using the ant task. To avoid name conflicts, only a
subset of the properties are passed to the external Ant build. These
include all properties defined in the properties section of the POM.
It also includes prefixed versions of some of the commonly used Maven
properties.
So here's my pom, where I define "test.prop" property:
<?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>testant</groupId>
<artifactId>testant</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<test.prop>TestPropValue</test.prop>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>optional</artifactId>
<version>1.5.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-index-properties</id>
<phase>install</phase>
<configuration>
<tasks>
<!--<property name="test.prop" value="${test.prop}"/>-->
<ant antfile="build.xml">
<target name="echo-prop"/>
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And just trying to echo this property in build.xml:
<project default="test">
<target name="echo-prop">
<echo>${test.prop}</echo>
</target>
</project>
This is what I get:
echo-prop:
[echo] ${test.prop}
So property is not resolved as it should, according to the doc.
And it works fine only in case if I uncomment line with explicit property declaration under "tasks" tag.
Could you please help me in understanding, what am I doing wrong?
Thank you!
You should specify a version for the antrun-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version><!--$NO-MVN-MAN-VER$-->
(...)
</plugin>
ant by default passes all properties of the parent to an underlying "ant"-call. Unless you define inheritAll=false, all properties are passed.
In this case, you should have a look at the effective pom. There a very ancient version of the antrun-plugin is defined.
As soon as you switch to a recent one, the example code works.

Maven flyway 4.0.3 - Executing multiple databases as part of a single pom

I read a lot of articles (on flyway and stackoverflow) before deciding to open a question. Mostly the solutions how to setup your pom for executing multiple databases using maven and flyway surround around version 3.0 of flyway.
I have a requirement where I have to connect to multiple schemas using different user accounts and execute totally different SQL's using flyway.
I tried to setup my pom as per article, but it fails to recognize multiple execution tags and also the id. It throws the error message
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:4.0.3:migrate (default-cli) on project Flyway_001: org.flywaydb.core.api.FlywayExce
ption: Unable to connect to the database. Configure the url, user and password! -> [Help 1]
My pom looks like
<?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.flyway</groupId>
<artifactId>Flyway_001</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}-${project.version}</name>
<properties>
<A.db.user>A_DB_USER</A.db.user>
<A.db.password>*******</A.db.password>
<A.db.schema>A_DB_SCHEMA</A.db.schema>
<A.db.url>jdbc:oracle:blah..blah</A.db.url>
<B.db.user>B_DB_USER</B.db.user>
<B.db.password>*******</B.db.password>
<B.db.schema>B_DB_SCHEMA</B.db.schema>
<B.db.url>jdbc:oracle:blah..blah</B.db.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>4.0.3</version>
<executions>
<execution>
<id>flyway-A</id>
<configuration>
<url>${A.db.url}</url>
<user>${A.db.user}</user>
<password>${A.db.password}</password>
<schemas>
<schema>${A.db.schema}</schema>
</schemas>
<table>T_HUB_SCHEMA_VERSION</table>
<baselineOnMigrate>false</baselineOnMigrate>
<locations>
<location>filesystem:src/main/resources/db/A</location>
</locations>
</configuration>
</execution>
<execution>
<id>flyway-B</id>
<configuration>
<url>${B.db.url}</url>
<user>${B.db.user}</user>
<password>${B.db.password}</password>
<schemas>
<schema>${B.db.schema}</schema>
</schemas>
<table>T_HUB_SCHEMA_VERSION</table>
<baselineOnMigrate>false</baselineOnMigrate>
<locations>
<location>filesystem:src/main/resources/db/B</location>
</locations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Has anyone tried connecting to multiple DB's using flyway 4.0? If so will appreciate if someone can give some guidance on whats wrong with my approach.
IDE complained about tags under execution element. Was able to get rid of the complains by specifying the goals tag like so:
<execution>
<id>some-id</id>
<goals>
<goal>migrate</goal>
</goals>
</execution>

want different maven project structure

Trying to understand maven flow.Need to create a folder called 'my-source' and copy multiple files in the same folder.
And i want a maven build zip file which should contain 'my-source' folder and its contents.How do i do that?Where ever articles i refer am seeing only java project/folder structure examples.
Also i have seen sourcedirectory/outputdirectory. Not sure where i can modify these values as i couldnot find location of effectivepom
So please give me the process to fulfil my requirement
In order to create a zip file with all your contents you will have to use the maven assembly plugin in your pom.xml. Apart from this, you will need one more file (say bin.xml) that will tell which all files you want to be packaged in the zip. The assembly plugin in the pom.xml will simply point to the bin.xml file.
See a sample code for pom.xml below.
<?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.abc</groupId>
<artifactId>xyz</artifactId>
<version>3.1.3</version>
<build>
<plugins>
<plugin> <!-- Create a zip file with the contents you want deployed -->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<descriptors>
<descriptor>src/assembly/bin.xml</descriptor> // very important. This is where we will tell where our bin.xml is located
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Now create a folder structure like src/assembly and add a file with the name bin.xml. See below for a sample code that should go inside bin.xml.
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>distrib</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/my-source</directory> // the folder that you want to the packaged in the zip file
<outputDirectory>/</outputDirectory> // the location within the zip file where your folder should be copied. In this case it will place the my-source directory at the root level of the zip file.
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
</assembly>

copy jars used by plugin to single folder using Maven

In my POM.xml other the plugin configuration, i am not required to configure any dependenices to run the plugin. I would like to download dependent jars used by plugin(soapui-maven-plugin) from the repository into one single folder. I tried the command "mvn dependency:copy-dependencies", but no jars are copied. Is there any way to do it?
<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>service.report</groupId>
<artifactId>service-report</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven 2 SoapUI Sample</name>
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>loadtest</goal>
</goals>
<configuration>
<projectFile>${basedir}/src/main/resources/xxxxx-soapui-project.xml</projectFile>
<testSuite>xxxx</testSuite>
<testCase>sssss</testCase>
<loadTest>LoadTest 1</loadTest>
<outputFolder>${basedir}/target/surefire</outputFolder>
<junitReport>true</junitReport>
<exportAll>true</exportAll>
<printReport>true</printReport>
<testFailIgnore>false</testFailIgnore>
<!-- <projectProperties>
<value>message=Hello World!</value>
</projectProperties> -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
mvn dependency:copy-dependencies is only applied to current maven module only. It won't works on plugins. If you want to download all soapui-maven-plugin dependencies, you need to execute command from soapui-maven-plugin project. You can follow the following steps. I assumed you familiar with GIT CLI. If not, you need to manually download from https://github.com/SmartBear/soapui
git clone https://github.com/SmartBear/soapui
cd soapui/soapui-maven-plugin
mvn dependency:copy-dependencies
You can get list of dependencies in soapui/soapui-maven-plugin/target/dependency (total 82files)
[ERROR] Failed to execute goal on project soapui-maven-plugin: Could not resolve dependencies for project com.smartbear.soapui:soapui-maven-plugin:maven-plugin:5.0.0: Could not find artifact javafx:jfxrt:jar:2.2 at specified path (your jdk path)
If you get the above error, it means your maven jdk is version jdk.1.7 (u6 or earlier) which is not installed with javafx. Download newer jdk that comes with javafx at http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html . Remember change your maven jdk to this newer jdk.
If you want to use the dependency-plugin you could add the dependencies to the pom...and download with the depepndency-plugin...
It works right for me...
<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.ab.forge.utility.copydependenciespom</groupId>
<artifactId>copydependenciespom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<!-- BINARIES -->
<dependencies>
<!--CUSTOMER RETURN -->
<dependency>
<groupId>com.ab...</groupId>
<artifactId>customerret.....</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<overWriteIfNewer>true</overWriteIfNewer>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<excludeGroupIds>com.ab.ah.scad.acl</excludeGroupIds>
<excludeTypes>pom</excludeTypes>
<includeGroupIds>com.ab.oneleo</includeGroupIds>
<outputDirectory>${outputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
After I just run the install passing the -DoutputDirectory parameter....
Try this...
To view all the plugin dependencies you can run a dependency:tree on the pom (where the plugin in configured)

Maven: how to use POM elements from within assembly descriptor

I need to assemble several sets of resources. These sets of resources are related to each other. So, I decided to put them all under the same project and use the assembly plugin to achieve my goal.
I have ended with a POM and a descriptor file for each set of resources.
Let's assume that my project is as follows:
src/main/resources/set1 : contains resources for the first set
src/main/resources/set2 : contains resources for the second set
src/main/resources/set3 : contains resources for the third set
descriptor1.xml : the assembly descriptor for the first set
descriptor2.xml : the assembly descriptor for the second set
descriptor3.xml : the assembly descriptor for the thord set
pom.xml
The content of descriptor1.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>set1</id>
<formats>
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<outputDirectory>/</outputDirectory>
<directory>${project.basedir}/src/main/resources/set1</directory>
</fileSet>
</fileSets>
</assembly>
The content of descriptor2.xml and descriptor3.xml is similar to the content of descriptor1.xml except that set1 (in "/assembly/id" and "/assembly/fieldSets/fieldSet/directory") is replaced by set2 and set3 respectively.
The content of 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>sample</groupId>
<artifactId>sample.assembler</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<properties>
<maven-assembly-plugin.version>2.4</maven-assembly-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<executions>
<execution>
<id>set1</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>descriptor1.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>set2</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>descriptor2.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>set3</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>descriptor3.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The above config gives the expected result. However, there are a lot of descriptor files to maintain.
I have read in the documentation that descriptor files are interpolated using project properties, POM element values, user properties, ... before being used.
My question is : is there a way to reference the id of the current execution (some thing like project.build.execution.id)? In such a case, all my three descriptors with be replaced by only one file.
Thank you in advance.
I don't think you can achieve what you want within single run.
But you can create a profiles where earch of the profile will define different properties and you can run your build three times with different profiles to get 3 different file sets.
I do use such approach for generating configuration for different environments. I activate the environment profile and the output is the environment configuration. The configuration is generated by single descriptor which is driven by the profile properties.
EDIT:
Here is a workaround using per-execution propeties which may solve your problem. In the moment I'm not entirely sure if these filters will be used for filtering resources only or you can reference them in the assembly itself for defining lets say <finalName> ...
See: http://olafsblog.sysbsb.de/per-assembly-filtering-with-the-maven-assembly-plugin/

Resources