liquibase plugin errors using maven - 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.

Related

Error during maven "clean install" with plug-in resolve

I try to to use clean install in Maven and get the error below. I have two questions:
Is this an error to be solved with a fair amount of work or is it such an esoteric error, that any attempt to solve it would end up in a long-term project?
Has anybody a solution in mind?
I can provide further info, if necessary. The java version is:
openjdk version "10.0.1" 2018-04-17
I'm running this on Ubuntu 18.04.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] DeepLearning4j Examples Parent
[INFO] DeepLearning4j Examples
[INFO] dl4j-spark-examples
[INFO] dl4j-spark
[INFO] datavec-examples
[INFO] DeepLearning4j CUDA special examples
[INFO] nd4j-examples
[INFO] Reinforcement Learning4j Examples
[INFO] lstm-hdfs
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DeepLearning4j Examples Parent 1.0.0-alpha
[INFO] ------------------------------------------------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.0.1/maven-enforcer-plugin-1.0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] DeepLearning4j Examples Parent ..................... FAILURE [ 1.359 s]
[INFO] DeepLearning4j Examples ............................ SKIPPED
[INFO] dl4j-spark-examples ................................ SKIPPED
[INFO] dl4j-spark ......................................... SKIPPED
[INFO] datavec-examples ................................... SKIPPED
[INFO] DeepLearning4j CUDA special examples ............... SKIPPED
[INFO] nd4j-examples ...................................... SKIPPED
[INFO] Reinforcement Learning4j Examples .................. SKIPPED
[INFO] lstm-hdfs .......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.774 s
[INFO] Finished at: 2018-05-01T21:23:04+02:00
[INFO] Final Memory: 8M/34M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-enforcer-plugin:1.0.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-enforcer-plugin:jar:1.0.1: Could not transfer artifact org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0.1 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -> [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/PluginResolutionException
Here is the pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-examples-parent</artifactId>
<version>1.0.0-alpha</version>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<name>DeepLearning4j Examples Parent</name>
<description>Examples of training different data sets</description>
<properties>
<!-- Change the nd4j.backend property to nd4j-cuda-8.0-platform, nd4j-cuda-9.0-platform or nd4j-cuda-9.1-platform to use CUDA GPUs -->
<nd4j.backend>nd4j-native-platform</nd4j.backend>
<!--<nd4j.backend>nd4j-cuda-9.1-platform</nd4j.backend>-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<shadedClassifier>bin</shadedClassifier>
<java.version>1.8</java.version>
<nd4j.version>1.0.0-alpha</nd4j.version>
<dl4j.version>1.0.0-alpha</dl4j.version>
<datavec.version>1.0.0-alpha</datavec.version>
<arbiter.version>1.0.0-alpha</arbiter.version>
<rl4j.version>1.0.0-alpha</rl4j.version>
<!-- For Spark examples: change the _1 to _2 to switch between Spark 1 and Spark 2 -->
<dl4j.spark.version>1.0.0-alpha_spark_1</dl4j.spark.version>
<datavec.spark.version>1.0.0-alpha_spark_1</datavec.spark.version>
<!-- Scala binary version: DL4J's Spark and UI functionality are released with both Scala 2.10 and 2.11 support -->
<scala.binary.version>2.11</scala.binary.version>
<hadoop.version>2.2.0</hadoop.version> <!-- Hadoop version used by Spark 1.6.3 and 2.2.1 (and likely others) -->
<guava.version>19.0</guava.version>
<logback.version>1.1.7</logback.version>
<jfreechart.version>1.0.13</jfreechart.version>
<jcommon.version>1.0.23</jcommon.version>
<maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
<maven.minimum.version>3.3.1</maven.minimum.version>
<javafx.version>2.2.3</javafx.version>
<javafx.runtime.lib.jar>${env.JAVAFX_HOME}/jfxrt.jar</javafx.runtime.lib.jar>
<aws.sdk.version>1.11.109</aws.sdk.version>
<jackson.version>2.6.6</jackson.version>
<scala.plugin.version>3.2.2</scala.plugin.version>
</properties>
<modules>
<module>dl4j-examples</module>
<module>dl4j-spark-examples</module>
<module>datavec-examples</module>
<module>dl4j-cuda-specific-examples</module>
<module>nd4j-examples</module>
<module>rl4j-examples</module>
<module>lstm-hdfs</module>
</modules>
<!-- Maven Enforcer: Ensures user has an up to date version of Maven before building -->
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-default</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[${maven.minimum.version},)</version>
<message>********** Minimum Maven Version is ${maven.minimum.version}. Please upgrade Maven before continuing (run "mvn --version" to check). **********</message>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- Automated Code Formatting -->
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<configFile>${session.executionRootDirectory}/contrib/formatter.xml</configFile>
<directories>
<directory>dl4j-examples</directory>
<directory>dl4j-spark-examples</directory>
<directory>datavec-examples</directory>
<directory>dl4j-cuda-specific-examples</directory>
<directory>nd4j-examples</directory>
<directory>rl4j-examples</directory>
<directory>arbiter-examples</directory>
<directory>lstm-hdfs</directory>
</directories>
</configuration>
</plugin>
<plugin>
<groupId>com.lewisd</groupId>
<artifactId>lint-maven-plugin</artifactId>
<version>0.0.11</version>
<configuration>
<failOnViolation>true</failOnViolation>
<onlyRunRules>
<rule>DuplicateDep</rule>
<rule>RedundantPluginVersion</rule>
<rule>VersionProp</rule>
<rule>DotVersionProperty</rule>
</onlyRunRules>
</configuration>
<executions>
<execution>
<id>pom-lint</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.lewisd</groupId>
<artifactId>lint-maven-plugin</artifactId>
<versionRange>[0.0.11,)</versionRange>
<goals>
<goal>check</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>OpenJFX</id>
<activation>
<jdk>1.7</jdk>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-default</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>env.JAVAFX_HOME</property>
<message>You must set the environment variable JAVAFX_HOME to the installation directory of the JavaFX 2.0 SDK! (with Oracle JDK1.7, $JRE_HOME/lib/jfxrt.jar)</message>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${javafx.runtime.lib.jar}</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

maven-enforcer-plugin and child pom

I am trying to use the maven-enforcer-plugin to ensure that one profile is activated (requireActiveProfile rule). See the second example on this page: Require Active Profile
It works well with a single pom file. When I try to use it with 2 pom files (a parent and a child) this do not work anymore when I try to build the child module.
I have any idea why it doesn’t work?
Complete example:
EXAMPLE
| pom.xml <1> (parent pom)
|
\---child
pom.xml <2> (child pom)
Parent pom file <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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app.parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<profiles>
<profile>
<id>first</id>
<properties>
<my-name>Alice</my-name>
</properties>
</profile>
<profile>
<id>second</id>
<properties>
<my-name>Bob</my-name>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-first-or-second-profile-is-active</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireActiveProfile>
<profiles>first,second</profiles>
<all>false</all>
</requireActiveProfile>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Hello ${my-name}!</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Child pom file <2>:
<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.mycompany.app</groupId>
<artifactId>my-app.parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>my-app</artifactId>
<packaging>pom</packaging>
</project>
Now I run:
EXAMPLE>cd child
EXAMPLE\child>mvn compile -Psecond
And the output looks like that:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-first-or-second-profile-is-active) # my-app ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireActiveProfile failed with message:
Profile "first" is not activated.
Profile "second" is not activated.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.178 s
[INFO] Finished at: 2015-10-30T18:03:50+01:00
[INFO] Final Memory: 24M/989M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-first-or-second-profile-is-active) on project my-app: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [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/MojoExecutionException
When I run maven on the parent pom, it works. What did I miss?
Maven Profiles are a bit confusing, but I'll venture an explanation based on my experiences.
The profile definitions is not inherited, but the effects of them are.
If you jump to the child directory and run mvn -Pfirst help:active-profiles you'll see that the effect of the parent's profile is indeed there:
Part of the output:
...
<properties>
<my-name>Alice</my-name>
</properties>
...
but you won't see the profiles definition in there.
The bad news is that your enforcer rule won't work in this scenario, unless every child also defines the required profiles.
The good news is that, armed with this new knowledge, you can use another enforcer rule (requireProperty) to achieve what you want:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-property</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>my-name</property>
<message>You must set a my-name property! Did you activate the right profile?</message>
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>

How to generate classes from wsdl using Maven and wsimport?

When I attempt to run "mvn generate-sources" this is my output :
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gensourcesfromwsdl 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.104s
[INFO] Finished at: Tue Aug 20 15:41:10 BST 2013
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
I do not receive any errors but there are no java classes generated from the wsdl file.
Here is my pom.xml file that I'm running the plugin against :
<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>gensourcesfromwsdl</groupId>
<artifactId>gensourcesfromwsdl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlLocation>http://mysite/firstwsdl.asmx?wsdl</wsdlLocation>
<packageName>com</packageName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
What am I doing wrong ? The package com exists in the project 'gensourcesfromwsdl' and the wsdl location is valid.
When I run wsimport via the command line : >wsimport -keep -verbose http://mysite/firstwsdl.asmx?wsdl the class is generated.
To generate classes from WSDL, all you need is build-helper-maven-plugin and jaxws-maven-plugin in your pom.xml
Make sure you have placed wsdl under folder src/main/resources/wsdl and corresponding schema in src/main/resources/schema, run command "mvn generate-sources" from Project root directory.
C:/Project root directory > mvn generate-sources
generated java classes can be located under folder
target/generated/src/main/java/com/raps/code/generate/ws.
pom.xml snippet
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${project.build.directory}/generated/src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<configuration>
<wsdlDirectory>${project.basedir}/src/main/resources/wsdl</wsdlDirectory>
<packageName>com.raps.code.generate.ws</packageName>
<keep>true</keep>
<sourceDestDir>${project.build.directory}/generated/src/main/java</sourceDestDir>
</configuration>
<executions>
<execution>
<id>myImport</id>
<goals><goal>wsimport</goal></goals>
</execution>
</executions>
</plugin>
Here is an example of how to generate classes from wsdl with jaxws maven plugin from a url or from a file location (from wsdl file location is commented).
<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">
<build>
<plugins>
<!-- usage of jax-ws maven plugin-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>wsimport-from-jdk</id>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- using wsdl from an url -->
<wsdlUrls>
<wsdlUrl>
http://myWSDLurl?wsdl
</wsdlUrl>
</wsdlUrls>
<!-- or using wsdls file directory -->
<!-- <wsdlDirectory>src/wsdl</wsdlDirectory> -->
<!-- which wsdl file -->
<!-- <wsdlFiles> -->
<!-- <wsdlFile>myWSDL.wsdl</wsdlFile> -->
<!--</wsdlFiles> -->
<!-- Keep generated files -->
<keep>true</keep>
<!-- Package name -->
<packageName>com.organization.name</packageName>
<!-- generated source files destination-->
<sourceDestDir>target/generatedclasses</sourceDestDir>
</configuration>
</plugin>
</plugins>
</build>
Even though this is bit late response, may be helpful for someone. Look like you have used pluginManagement. If you use pluginManagement
, it will not pick the plug-in execution.
It should be under
<build>
<plugins>
<plugin>
Try to wrap wsdlLocation in wsdlUrls
<wsdlUrls>
<wsdlLocation>http://url</wsdlLocation>
</wsdlUrls>
I see some people prefer to generate sources into the target via jaxws-maven-plugin AND make this classes visible in source via build-helper-maven-plugin. As an argument for this structure
the version management system (svn/etc.) would always notice changed
sources
With git it is not true. So you can just configure jaxws-maven-plugin to put them into your sources, but not under the target folder. Next time you build your project, git will not mark these generated files as changed. Here is the simple solution with only one plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.6</version>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-fluent-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>som.path.generated</packageName>
<xjcArgs>
<xjcArg>-Xfluent-api</xjcArg>
</xjcArgs>
<verbose>true</verbose>
<keep>true</keep> <!--used by default-->
<sourceDestDir>${project.build.sourceDirectory}</sourceDestDir>
<wsdlDirectory>src/main/resources/META-INF/wsdl</wsdlDirectory>
<wsdlLocation>META-INF/wsdl/soap.wsdl</wsdlLocation>
</configuration>
</execution>
</executions>
</plugin>
Additionally (just to note) in this example SOAP classes are generated with Fluent API, so you can create them like:
A a = new A()
.withField1(value1)
.withField2(value2);
The key here is keep option of wsimport. And it is configured using element in
About keep from the wsimport documentation :
-keep keep generated files
i was having the same issue while generating the classes from wsimport goal. Instead of using jaxws:wsimport goal in eclipse Maven Build i was using clean compile install that was not able to generate code from wsdl file. Thanks to above example.
Run jaxws:wsimport goal from Eclipse ide and it will work

Possible bug when parsing properties with goal "regex-property" of build-helper-maven-plugin?

The requirement is that I have to parse a system property with regex in order to remove the dot from the value.
Execution example is: mvn install -Dsomeversion=1.3
pom.xml configuration is:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>someversion.parsed</name>
<value>$\{someversion}</value>
<regex>(.*)[\._](.*)</regex>
<replacement>$1$2</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
Based on the plugin's documentation, the backslash must be there after the dollar sign in <value>
The issues are:
When the backslash is there, the system property is not parsed
If I remove the backslash:
a) system property is parsed successfully
b) if execute "mvn install" I am getting the error that the parameter 'value' is
missing or incorrect, despite the fact that I have configured <failIfNoMatch>false</failIfNoMatch>
Any feedback would be highly appreciated
Thank you in advance
after some tests, I came to following conclusion:
didn't see the documentation stating that '\' should follow '$' sign
(maybe you can point me to it), so I removed it :), anyway escaping usually achieved by - '\' is relevant for next rather than previous character, as far as I know
for the errror you see for mvn install is value of the config
property <failIfNoMatch> irrelevant
The <failIfNoMatch> decides, should I fail if the system property is there but is not in the expected format? It doens't cover the case that property is not there at all. However for this purpose, in maven exist so called profiles, these can be activated in a different ways, one of them is system property presence.
So the following does the job for me:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>sample</groupId>
<artifactId>sample</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<profiles>
<profile>
<activation>
<property>
<name>someversion</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>someversion.parsed</name>
<value>${someversion}</value>
<regex>(.*)[\._](.*)</regex>
<!-- <regex>notmatched</regex>-->
<replacement>$1$2</replacement>
<failIfNoMatch>false</failIfNoMatch>
<!--<failIfNoMatch>true</failIfNoMatch>-->
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>******** Displaying value of property ********</echo>
<echo>${someversion.parsed}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Please note that maven-antrun-plugin is there just to show debugging output.
Now some tests:
mvn install -Dsomeversion=1.3
...
main:
[echo] ******** Displaying value of property ********
[echo] 13
[INFO] Executed tasks
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
...
For no system property version:
mvn install
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
...
Without having special profile stuff in my pom.xml I'd get following output:
mvn install
...
INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] One or more required plugin parameters are invalid/missing for 'build-helper:regex-property'
[0] Inside the definition for plugin 'build-helper-maven-plugin' specify the following:
<configuration>
...
<value>VALUE</value>
</configuration>
-OR-
on the command line, specify: '-Dsomeversion=VALUE'
...
And just to make things complete, in case I'd use in my solution (currently commented out) <regex>notmatched</regex> as well as <failIfNoMatch>true</failIfNoMatch>:
mvn install -Dsomeversion=1.3
...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - sample:sample:pom:1.0.0-SNAPSHOT
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [build-helper:regex-property {execution: regex-property}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] No match to regex 'notmatched' found in '1.3'.
[INFO] ------------------------------------------------------------------------
...
Please note, that last 2 errors differ - one is for missing property and the other one for the non-matching regexp.
So just to sum up, I believe that build-helper-maven-plugin works as expected.

Maven Jaxb2 xjc plugin error No schemas have been found

These days I've spent some time on JAXB for converting XSD to Java Class and vice versa. Here's a very good tutorial for beginners, http://www.journaldev.com/1312/how-to-generate-java-classes-from-xsd-using-xjc-maven-plugin. I follow the steps strictly, but always get error when mvn clean install
Here's my pom.xml file.
<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>jd</groupId>
<artifactId>jd</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- Plugin required to build java classes from XSD using XJC -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The name of your generated source package -->
<arguments>-extension -npa -b ${project.basedir}/src/main/java/com/moodys/jaxb/global.xjb</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
But when I type mvn clean install, it always give me error as following:
C:\Users\congy\Desktop\Work\workspace\JaxbFromClass>mvn clean jaxb2:xjc
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jd 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # jd ---
[INFO] Deleting C:\Users\congy\Desktop\Work\workspace\JaxbFromClass\target
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (default-cli) # jd ---
[INFO] Generating source...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.487s
[INFO] Finished at: Thu Jul 04 19:09:37 CST 2013
[INFO] Final Memory: 4M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.5:xjc (default-cli) on project jd: No schemas have been found -> [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/MojoExecutionException
Can anyone show me the cause or simply tell me what should I refer to for further information?
Another question is : according to this question Difference of Maven JAXB plugins, there's at least three jaxb plugins. So all of these plugins are all generated for the same purposes? If so ,why?
Thanks in advance!
As you did not provide any schemaDirectory, the plugin is trying to generate Java sources from all XML schema files in the default schema directory. You should configure the plugin according to the documentation :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>id1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/jaxb</outputDirectory>
<packageName>com.your.package.jaxb</packageName>
<schemaDirectory>src/main/xsd</schemaDirectory>
<schemaFiles>jaxb.xsd</schemaFiles>
</configuration>
</execution>
</executions>
</plugin>
Try to make sure that jaxb.xsd is present under src/main/resources, the plugin is waring since it coudn't find the scheme in the specified location.
We can use as below in pom.xml file
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>id1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<outputDirectory>src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
<packageName>com.subu.xsd.model</packageName>
<schemaDirectory>src/main/java/schemadir</schemaDirectory>
<schemaFiles>XYZ.xsd</schemaFiles>
</configuration>
</execution>
</executions>
</plugin>
The OP already got their answer, but I ran into this same problem for a different reason...
I introduced a new class that JAXB wasn't generating source for. This is because I used a parameterized constructor. Once I added a no-arg constructor the problem was fixed.

Resources