How to create a .jar out of multiple jars using Maven Plugin - maven

I have a project which has multiple .jar files in it. To add this as a dependency, I need to turn all these jars into one big jar. So far I have come until:
<?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>mainProjects</groupId>
<artifactId>mainProjects.master</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>mainProjects</groupId>
<artifactId>sampleModule1</artifactId>
<name>sampleModule1</name>
<version>1.0.0.qualifier</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>Sample1.jar</include>
<include>Sample2.jar</include>
</includes>
</artifactSet>
<finalName>${project.artifactId}-${project.version}-final</finalName>
<outputDirectory>${project.artifactId}/build</outputDirectory>
<shadedArtifactAttached>false</shadedArtifactAttached>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This creates the final jar, however, inside there are no content from the other jars (sample1.jar and sample2.jar) as there should be. I have looked into the documentation of the plugin, however all they did was to do it via class files, not jars. So I don't know how to proceed from now on.
Any thoughts?
Update:
So in order to make it clear, hereby I share the project structure that I have:
+- mainProjects
| +- pom.xml
| +- mainProject1
| | +- pom.xml
| | +- src
| +- mainProject2
| | +- pom.xml
| | +- src
| +- group1
| | +- pom.xml
| | +- sampleModule1
| | | +- pom.xml
| | | +- build
| | | +- sample1.jar
| | | +- sample2.jar
| | | +- sample3.jar
| | | +- sample4.jar
| | | +- sample5.jar
| | | +- sample6.jar
| | +- sampleModule2
| | | +- pom.xml
| | | +- src
Now, I want to be able to use sampleModule1 as a dependency in the pom.xml of mainProject1 as a jar, like this:
<dependency>
<groupId>group1</groupId>
<artifactId>sampleModule1</artifactId>
<version>1.0.0.qualifier</version>
<scope>system</scope>
<systemPath>sampleModule1/build/${project.artifactId}-${project.version}-final.jar</systemPath>
</dependency>
to achieve this, I need to compile all the jars into one jar, so that I can add it by using one systemPath. I found this which shows an example of how to include multiple files into one. However, in the example they are not jars, but rather classes and others. Now here, I am trying to achieve the same, but with only jars.

There are two ways to solve your problem! If you just want to to add files into your jar, you can use the resources tags to add them
<build>
<resources>
<resource>
<filtering>false</filtering>
<directory>lib</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</build>
This now puts all jar files from you lib folder into the main jar. The root folder is the folder from which you invoked the corresponding pom.xml. With this you can add arbitrary files to you jar. For a complete syntax reference take a look here.
The other way and maybe the most convenient way is to use the maven-shade-plugin this allows you to copy almost everything into you final jar.
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>groupid:artifactid_a</include>
<include>groupid:artifactid_b</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<includes>
<include>resources/*.png</include>
</includes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
The artifactSet parts allow you to reference jar from within you local repro to be included just by mentioning their groupid and artifactid
This will include the content like class files, manifest etc. and also the folder structure) of the mentioned artifact (from you local repro) into you jar.
If you want to include other arbitrary files into you jar you can use the filter tag of the plugin which allows you to specify files and file-patterns directly. For a complete syntax reference take a look here.
P.S.: If you want to exclude certain files you can replace the include tag by an exclude tag ;-)

Related

How to setup Maven Archetype to generate module project at same level as parent project?

I want to create a maven archetype which should generate child module projects at the same level as parent project. So the structure will look like -
- parent
|_ pom.xml
|_ <rest-of-the-files>
- child1
|_ pom.xml
|_ <rest-of-the-files>
- child2
|_ pom.xml
|_ <rest-of-the-files>
The parent pom.xml will have modules like -
<modules>
<module>../child1</module>
<module>../child2</module>
</modules>
Is there any way to achieve this?
See answer to Error installing a multimodule archetype created with mvn archetype:create-from-project:
It looks like the archetype plugin doesn't support flat layout for multi-module projects.
You can use the following (agreed, a bit cumbersome) workaround:
Create your projects as:
+- parent
+- pom.xml
+- ...
|
+- child1
| +- pom.xml
| +- ...
|
+- child2
+- pom.xml
+- ...
Create another project in parent/src/main/resources:
+- parent
+- pom.xml
+- ...
+- src
+- main
+- resources
+- pom.xml
with the POM like:
...
<artifactId>move-modules</artifactId>
...
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<configuration>
<target>
<echo level="info">Moving modules...</echo>
<move file="../../../../child1" tofile="../../../../../child1" failonerror="false" />
<move file="../../../../child2" tofile="../../../../../child2" failonerror="false" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Generate, install/deploy and use your archetype according to Maven Archetype Plugin, Advanced Usage/Archetype creation.
new/project/created/above/src/main/resources/move-modules $ mvn initialize
Adapt <module>s in your parent POM:
<modules>
<module>../child1</module>
<module>../child2</module>
</modules>

Running external Ant file from a parent pom

I would like to run an Ant build.xml build from a parent POM.
This may look like this:
<project>
<groupId>my.group</groupId>
<artifactId>my-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<configuration>
<tasks>
<ant antfile="build.xml"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This works just fine unless I use this module as a parent POM.
The problem is in this line <ant antfile="build.xml"/>. While this POM is running as a parent POM there is no build.xml file available to the plugin.
How can I run an Ant script from a file (located in the parent POM) during all child build?
PS
I tried to package the build.xml under some classifier to make it available to the children builds. But I have no idea, how can I extract my packaged build.xml prior to the antrun:run.
PPS
The project structure:
<root>
+ Parent POM
| +- pom.xml
| +- build.xml
|
+ Component1
| + Child1
| | +- src/main/java
| | +- ...
| | +- pom.xml
| |
| + Child2
| +- src/main/java
| +-...
| +- pom.xml
|
+ Component2
+ Child3
| +- src/main/java
| +- ...
| +- pom.xml
|
+ Child4
+- src/main/java
+-...
+- pom.xml
As a bonus: I also would like to know the answer for the situations, where the parent POM get built and deployed independently (not knowing own child) and children get built having only access to the parent deployed artifacts (not the source code).
To avoid the FileNotFoundException you could use a configured property as prefix of the ant build file. Such a property would be empty on the parent pom while would have the right prefix (i.e. relative path to parent folder) in the required modules.
For instance, in your parent POM your configuration would look like:
<properties>
<ant.build.dir.prefix></ant.build.dir.prefix>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<configuration>
<tasks>
<ant antfile="${ant.build.dir.prefix}build.xml" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Note the ${ant.build.dir.prefix} prefix added to the ant invocation. By default it will be empty, which means file would be supposed to be located in the same directory as the pom.
However, in modules you would just need to override the value of the property, as following:
<properties>
<ant.build.dir.prefix>..\</ant.build.dir.prefix>
</properties>
Or any other relative path in the folders hierarchy.
At runtime, the value will be replaced and as such the path to the ant file will dynamically change, enforcing a common and centralized configuration of the ant run (in the parent pom) and a specific path configuration in modules (via a property prefix).
I just tested both cases (your configuration and the prefixed one) in a sample project with an echo ant task, being able to reproduce your issue and to fix it as suggested above.

How to use checkstyle:check in a multi module project

I'm trying to use Maven Checkstyle plugin in a multi module project.
The default setting for <sourceDirectories> (where the plugin to start looking for code) is ${project.compileSourceRoots}. This resolves to [C:\workspace\projectname\src\main\java] in my case, i.e. a List<String>.
Now, that default path is of no value to me, since my code resides in different places, like so: [C:\workspaces\projectname\module1\src\main\java]. Hence, I need to change <sourceDirectories> to a list of directories where my code actually is.
So far, so good...
The problem is that <sourceDirectories> expects a List<String>. I tried the following:
<sourceDirectories>
<sourceDirectory>pathToCode1</sourceDirectory>
<sourceDirectory>pathToCode2</sourceDirectory>
</sourceDirectories>
... but that didn't work. It will take the default path. (Moreover, <sourceDirectory> is deprecated!)
Having only one <sourceDirectory> (without the surrounding <sourceDirectories>) does work, but <sourceDirectory> only takes one path and you can't have more than one <sourceDirectory>. So, no cigar. Also, keep in mind <sourceDirectory> is deprecated.
I also tried various other methods of providing a List<String> to <sourceDirectories>, but alas, no progress. Here are some examples:
<sourceDirectories>[pathToCode]</sourceDirectories>
<sourceDirectories>pathToCode</sourceDirectories>
<sourceDirectories>{pathToCode}</sourceDirectories>
<sourceDirectories>{[pathToCode]}</sourceDirectories>
<sourceDirectories>{{pathToCode}}</sourceDirectories>
<sourceDirectories>{{{pathToCode}}}</sourceDirectories>
Is there another way of (directly, without "sub-tags") providing a List<String> to maven?
Is the plugin broken?
Have I missed something?
Edits below
My project structure:
MyProject
|-- pom.xml <-- plugin runs fine here
|-- domain-module
| |-- src
| | `-- main
| | `-- com/example/hello...
| | |-- TheCode.java
| | `-- resources
| | |-- checkstyle.xml
| | `-- LICENSE.TXT
| `-- pom.xml
|-- poms
| |-- parent
| | `-- pom.xml <-- this is my parent pom
My parent pom
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.16</version>
<dependencies>
<dependency>
<groupId>com.example.hello</groupId>
<artifactId>domain-module</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>domain-module/src/main/resources/checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
<logViolationsToConsole>true</logViolationsToConsole>
<skip>false</skip>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<...>
</build>
</pluginManagement>
</plugins>
Since version 2.13 the use of sourceDirectories is broken (https://issues.apache.org/jira/browse/MCHECKSTYLE-260).
With 2.12 it works. Andreas Dangel mentioned in Jira:
The configuration described here
Checkstyle - Exclude folder
still works. Then the exclusion happens in checkstyle, rather than in
maven-checkstyle-plugin.

How to manage multiple profiles in Jhipster

Taken by example the jhipster-sample-app how can I manage multiple profiles, given that the same application will be installed in several machines having different configurations?
Since the deployment will be made using the apache tomcat, and it could be running one or more jhipster based apps, I would like to avoid using
-Dspring.profiles.active=MY_PROFILE
in the JAVA_OPTS variable.
Also it could happen to run the same application with different profiles on the same tomcat instance.
Taking profiles for the configuration of an application to support different environments like dev, test, prod is a bad idea.
Let us assume you have defined to make it simple three profiles like dev,test,prod. So now you build for dev environment like this:
mvn -Pdev clean package
Ok now you can take your artifact and deploy it. Next time you need for test environment you have to go like this:
mvn -Ptest clean package
You can take your artifact and deploy it. But what happens if you like to create for two environments or for three?
mvn -Pdev,test,prod clean package
This will usually fail, cause it's really tricky (and in same areas impossible) to handle different profiles to produce three different artifacts. So the best practice is to remove profiles and let your build produce just by:
mvn clean package
all the packages you need one for dev, one for test and one for prod.
One solution is to create a project structure like this:
.
|-- pom.xml
`-- src
|-- main
| |-- java
| |-- resources
| |-- environment
| | |-- test
| | | `-- database.properties
| | |-- qa
| | | `-- database.properties
| | `-- production
| | `-- database.properties
| `-- webapp
The different folders and property files are place holders just to show the path.
Next you need an assembly-descriptor one for each environment like this:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>test</id>
<formats>
<format>war</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>true</unpack>
<useProjectArtifact>true</useProjectArtifact>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<outputDirectory>WEB-INF</outputDirectory>
<directory>${basedir}/src/main/environment/test/</directory>
<includes>
<include>**</include>
</includes>
</fileSet>
</fileSets>
</assembly>
And finally you need to configure the maven-assembly-plugin like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>test</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/test.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>qa</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/qa.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>production</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/production.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
In the end this will produce the following artifacts: artifact-VERSION-dev.war, artifact-VERSION-test.war and artifact-VERSION-prod.war with a single call of Maven. If you take a deeper look into that blog article the above can made much more elegant.

liquibase plugin errors using maven

Hi i'm new to liquibase , and i'm importing an existing project after compile it i get this build failure , i can't understand the cause and the solution i'm trying to understand the code but i really find problem to do it .
this is the result after running mvn compile
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.squashtest.tm:squashtest-csp-distribution:pom:1.2.0.RELEASE
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.core.log4j:jar -> duplicate declaration of version ${project.version} # line 419, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.core.jetty.start.osgi:jar -> duplicate declaration of version ${project.version} # line 424, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.core.service:jar -> duplicate declaration of version ${project.version} # line 450, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:squashtest-csp-launcher:jar -> duplicate declaration of version ${project.version} # line 455, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.tm.web:war -> duplicate declaration of version ${project.version} # line 461, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.tm.service:jar -> duplicate declaration of version ${project.version} # line 467, column 17
[WARNING] 'profiles.profile[build-mysql].plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.codehaus.mojo:sql-maven-plugin # line 682, column 15
[WARNING] 'profiles.profile[build-mysql].plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.liquibase:liquibase-maven-plugin # line 724, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building squashtest-tm-distribution 1.2.0.RELEASE
[INFO] ------------------------------------------------------------------------
[WARNING] Failed to retrieve plugin descriptor for org.codehaus.izpack:izpack-maven-plugin:1.0-alpha-5: Plugin org.codehaus.izpack:izpack-maven-plugin:1.0-alpha-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.izpack:izpack-maven-plugin:jar:1.0-alpha-5
[INFO]
[INFO] --- liquibase-maven-plugin:2.0.1:update (default-cli) # squashtest-csp-distribution ---
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:12.500s
[INFO] Finished at: Fri Jul 13 10:25:08 GMT+01:00 2012
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:2.0.1:update (default-cli) on project squashtest-csp-distribution: The driver has not been specified either as a parameter or in a properties file. -> [Help 1]**
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Here's the pom.xml liquibase part :
<!-- We first run a full install against MySQL -->
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<configuration>
<skip>${mysql.distro.skip}</skip>
</configuration>
<executions>
<execution>
<id>generate-mysql-full-install-script</id>
<phase>process-resources</phase>
<goals>
<goal>updateSQL</goal>
</goals>
<configuration>
<dropFirst>true</dropFirst>
<changeLogFile>${master.changelog}</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>${liquibase.mysql.url}</url>
<username>${liquibase.mysql.username}</username>
<password>${liquibase.mysql.password}</password>
<migrationSqlOutputFile>${database.script.directory}/mysql-full-install-
version-${project.version}.sql</migrationSqlOutputFile>
</configuration>
</execution>
</executions>
</plugin>
<!-- We now run an incremental install against MySQL -->
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<configuration>
<skip>${mysql.distro.skip}</skip>
</configuration>
<executions>
<execution>
<id>generate-mysql-0.15.0-script</id>
<phase>prepare-package</phase>
<goals>
<goal>updateSQL</goal>
</goals>
<configuration>
<dropFirst>true</dropFirst>
<changeLogFile>${upgrade.0.15.0.changelog}</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>${liquibase.mysql.url}</url>
<username>${liquibase.mysql.username}</username>
<password>${liquibase.mysql.password}</password>
<migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
to-0.15.0.sql</migrationSqlOutputFile>
</configuration>
</execution>
<execution>
<id>generate-mysql-0.17.0-script</id>
<phase>prepare-package</phase>
<goals>
<goal>updateSQL</goal>
</goals>
<configuration>
<dropFirst>false</dropFirst>
<changeLogFile>${upgrade.0.17.0.changelog}</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>${liquibase.mysql.url}</url>
<username>${liquibase.mysql.username}</username>
<password>${liquibase.mysql.password}</password>
<migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
to-0.17.0.sql</migrationSqlOutputFile>
</configuration>
</execution>
<execution>
<id>generate-mysql-0.20.0-script</id>
<phase>prepare-package</phase>
<goals>
<goal>updateSQL</goal>
</goals>
<configuration>
<dropFirst>false</dropFirst>
<changeLogFile>${upgrade.0.20.0.changelog}</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>${liquibase.mysql.url}</url>
<username>${liquibase.mysql.username}</username>
<password>${liquibase.mysql.password}</password>
<migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
to-0.20.0.sql</migrationSqlOutputFile>
</configuration>
</execution>
<execution>
<id>generate-mysql-0.23.0-script</id>
<phase>prepare-package</phase>
<goals>
<goal>updateSQL</goal>
</goals>
<configuration>
<dropFirst>false</dropFirst>
<changeLogFile>${upgrade.0.23.0.changelog}</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>${liquibase.mysql.url}</url>
<username>${liquibase.mysql.username}</username>
<password>${liquibase.mysql.password}</password>
<migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
to-0.23.0.sql</migrationSqlOutputFile>
</configuration>
</execution>
<execution>
<id>generate-mysql-1.1.0-script</id>
<phase>prepare-package</phase>
<goals>
<goal>updateSQL</goal>
</goals>
<configuration>
<dropFirst>false</dropFirst>
<changeLogFile>${upgrade.1.1.0.changelog}</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>${liquibase.mysql.url}</url>
<username>${liquibase.mysql.username}</username>
<password>${liquibase.mysql.password}</password>
<migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
to-1.1.0.sql</migrationSqlOutputFile>
</configuration>
</execution>
<execution>
<id>generate-mysql-1.1.1-script</id>
<phase>prepare-package</phase>
<goals>
<goal>updateSQL</goal>
</goals>
<configuration>
<dropFirst>false</dropFirst>
<changeLogFile>${upgrade.1.1.1.changelog}</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>${liquibase.mysql.url}</url>
<username>${liquibase.mysql.username}</username>
<password>${liquibase.mysql.password}</password>
<migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
to-1.1.1.sql</migrationSqlOutputFile>
</configuration>
</execution>
<execution>
<id>generate-mysql-1.2.0-script</id>
<phase>prepare-package</phase>
<goals>
<goal>updateSQL</goal>
</goals>
<configuration>
<dropFirst>false</dropFirst>
<changeLogFile>${upgrade.1.2.0.changelog}</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>${liquibase.mysql.url}</url>
<username>${liquibase.mysql.username}</username>
<password>${liquibase.mysql.password}</password>
<migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
to-${squashTmVersion}.sql</migrationSqlOutputFile>
</configuration>
</execution>
</executions>
</plugin>
You receive this error because the value of the url is provided by a maven property, referred as ${liquibase.mysql.url}
You can set the value for maven properties in your pom like:
<project>
[...]
<properties>
<liquibase.mysql.url>jdbc:mysql://127.0.0.1:3306</liquibase.mysql.url>
<liquibase.mysql.username>someuser</liquibase.mysql.username>
[...]
</properties>
[...]
The liquibase plugin also provides possibility to read the configuration properties from a property file e.g. src/main/resources/liquibase.properties
If you choose this, you need to configure the liquibase maven plugin by replacing the conofiguration section in the pom like:
[...]
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
[...]
Then the liquibase properties should look like
url=jdbc:mysql://127.0.0.1:3306
username=someuser
dropFirst=true
changeLogFile=yourfile
[...]
More information is here: http://www.liquibase.org/documentation/maven/index.html#using_configuration_property_files
You need to set your variables ${liquabase.mysql.url} and so forth in your .m2/settings.xml. More details here: Missing maven .m2 folder
You also need to run mvn liquibase:update
First of all you are using a phase process-resource, which is basically used when you want to work on your changeLog from the output target directories, and if you are trying to use the filtering in your resource files using maven resource filtering plugin.
And I don't know for what purpose you are actually using the prepare-package or any such phase multiple times, maven with liquibase is not setup like this, you should have one master changelog, which should include your other upgrades, with some preCondition checks in each of your upgrades.
Your directory structure should be something like following, if you want to use your process-resource phase, and intended to do some kind of filtering in resource files.
src/
`-- main
|-- java
`-- resources
|-- changelog-1.0.0.xml
|-- changelog-1.1.0.xml
|-- changelog-install.xml
|-- com
| `-- obolus
| `-- database
| `-- changelog
| |-- v000
| | |-- cst
| | | |-- entity_extra_data.xml
| | | `-- entity.xml
| | |-- master.xml
| | `-- tab
| | |-- company.xml
| | |-- entity_extra_data.xml
| | |-- entity.xml
| | `-- anothertable.xml
| `-- v001
| |-- master.xml
| `-- tab
| `-- sample.xml
|-- lib
| |-- ojdbc6-11.2.0.3.jar
`-- liquibase.properties
Example of POM file
<?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.obolus</groupId>
<artifactId>database</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.maven.plugin}</version>
<configuration>
<changeLogFile>target/classes/changelog-install.xml</changeLogFile
<propertyFile>target/classes/liquibase.properties</propertyFile>
<logging>${logLevel}</logging>
</configuration>
<executions>
<execution>
<goals>
<goal>status</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<!-- resource filtering -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${ojdbc.driver.version}</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<ojdbc.driver.version>11.2.0.3</ojdbc.driver.version>
<liquibase.maven.plugin>3.3.2</liquibase.maven.plugin>
<logLevel>severe</logLevel>
</properties>
</project>
Hope that helps.

Resources