maven sql plugin 0 of 0 SQL statements executed successfully - maven

What i want is to be able to create/drop db from maven (if it is possible). I've found maven sql plugin but can't understand how to, for example, create db. Somehow maven says me that no sql commands. Can anyone help me with this problem?
Here is the result
d:\Projects\Learn\hibernate>mvn sql:execute
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building App 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sql-maven-plugin:1.5:execute (default-cli) # learn ---
[INFO] 0 of 0 SQL statements executed successfully
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.027s
[INFO] Finished at: Wed Sep 18 11:34:25 MSK 2013
[INFO] Final Memory: 8M/107M
[INFO] ------------------------------------------------------------------------
And the pom:
<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>learn-hibernate</groupId>
<artifactId>learn</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>App</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<mainClass>App.App</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
</dependencies>
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432</url>
<username>postgres</username>
<password>123456</password>
</configuration>
<executions>
<execution>
<id>default</id>
<phase>compile</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>jdbc:postgressql://localhost:5432</url>
<!-- no transaction -->
<autocommit>true</autocommit>
<sqlCommand>create database "hib"</sqlCommand>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

There is a typo in one of your URLs, postgressql must be postgresql.
When you run mvn sql:execute it is only picking up the plugin configuration, not a plugin execution, unless you give it the id default-cli (yours had just default).
The plugin execution that you had configured may have worked when running a normal lifecycle such as mvn compile or mvn install (as opposed to mvn sql:execute), however, for that to work you need a plugins.plugin definition (as opposed to a pluginManagement.plugins.plugin definition.
You can in fact CREATE and DROP databases using this plugin. I've done it and used it extensively for unit testing. We had four stages:
Create database. Executed from the generic database
Run DDL. Executed from the newly created database
Run unit test
Drop database. Executed from the generic database
If the unit test fails your database does not get dropped, which may be a good thing for analysis. This does mean that creating the database has to deal with the to-be-created database already being there (onError=continue).

Related

Maven returns exit 0 even though junit5 tests fail

I have setup Maven to trigger some junit5 tests.
When I run:
mvn clean integration-test
I see the project build and then it also runs the tests. I see a failure in one of the unit tests.
Further down in the console output, I see:
[INFO] BUILD SUCCESS
What am I doing wrong? My expectation is that a failed test run would stop a tool like maven and return exit code 1.
This is particularly frustrating in CI because it appears as the tests are healthy since exit code returns zero.
EDIT: Here's the POM XML:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.(removedforstackoverflowpost)</groupId>
<artifactId>(removedforstackoverflowpost)</artifactId>
<packaging>jar</packaging>
<version>0.0.1</version>
<name>(removedforstackoverflowpost)</name>
<url>(removedforstackoverflowpost)</url>
<description>(removedforstackoverflowpost)</description>
<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<developers>
<developer>
<name>(removedforstackoverflowpost)</name>
<email>(removedforstackoverflowpost)</email>
<organization>(removedforstackoverflowpost)</organization>
<organizationUrl>(removedforstackoverflowpost)</organizationUrl>
</developer>
</developers>
<scm>
<connection>(removedforstackoverflowpost)</connection>
<developerConnection>(removedforstackoverflowpost)</developerConnection>
<url>(removedforstackoverflowpost)</url>
</scm>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-console-standalone</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<!-- latest version (2.20.1) does not work well with JUnit5 -->
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.3</version>
</dependency>
</dependencies>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<properties>
<configurationParameters>
junit.jupiter.extensions.autodetection.enabled = true
</configurationParameters>
</properties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm running java 11
When I enter this test command:
mvn -ff clean integration-test
I get this output that ends like this:
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec - in com.github.(removedforstackoverflowpost)
Results :
Failed tests:
SomeTest.testSomething1:13 expected: <1> but was: <2>
Tests run: 4, Failures: 1, Errors: 0, Skipped: 0
[ERROR] There are test failures.
Please refer to (removedforstackoverflowpost)/target/surefire-reports for the individual test results.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # (removedforstackoverflowpost) ---
[INFO] Building jar: (removedforstackoverflowpost)....-0.0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.360 s
[INFO] Finished at: 2018-12-12T00:45:03-08:00
[INFO] ------------------------------------------------------------------------
I'm a total beginner so I apologize for asking an overly simplistic question. I am new to Java/Maven/JUnit5, but I'm just looking for what I should do to have the test cause a non zero exit code. This way, my CI run (I happen to use CircleCI but that doesnt matter) would show as failed when the tests fail.
I work on a Mac and the undesired behavior that I'm describing on this ticket happens the same way on both my local Mac workstation as well as in CircleCI.
Line 102 of your pom.xml is instructing Maven to ignore the failures. Just remove <testFailureIgnore>true</testFailureIgnore> and the build will fail.

Maven error from Jenkins

I am running Jenkins 1.599. I have created a new freeStyle project, which executes the batch command mvn clean install.
If I do run the same batch command from the windows shell, the maven command runs successfully.
However, when Jenkins executes it, I get a maven failure, as shown below:
C:\Program Files (x86)\Jenkins\jobs\AppHistData Freestyle\workspace>[workspace] $ cmd /c call C:\Windows\TEMP\hudson3523791316528515292.bat
C:\Program Files (x86)\Jenkins\jobs\AppHistData Freestyle\workspace>C:\\develop\\AppHistData\\AppHistDataMvn\\maven_run.bat
C:\Program Files (x86)\Jenkins\jobs\AppHistData Freestyle\workspace>cd C:\develop\AppHistData\AppHistDataMvn
C:\develop\AppHistData\AppHistDataMvn>C:\maven-3.2.5\bin\mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building AppHistDataMvn 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for TradingInstrument:TradingInstrument:jar:1 is missing, no dependency information available
[WARNING] The POM for allinonetrade:allinonetrade:jar:1 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.823 s
[INFO] Finished at: 2015-03-04T12:21:16+01:00
[INFO] Final Memory: 15M/491M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project AppHistDataMvn: Could not resolve dependencies for project com.deepfieldcapital:AppHistDataMvn:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: TradingInstrument:TradingInstrument:jar:1, allinonetrade:allinonetrade:jar:1: Failure to find TradingInstrument:TradingInstrument:jar:1 in http://bits.netbeans.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of maven2-repository.netbeans.maven2 has elapsed or updates are forced -> [Help 1]
[ERROR]
The POM.xml is as 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>deepFieldCapital</groupId>
<artifactId>TradeInstManager</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TradeInstManager</name>
<organization>
<name>Deep Field Capital</name>
</organization>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.deepfieldcapital.tradeinstmanager.TradeInstrumentManagerMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>lib</id>
<url>file:../lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.31</version>
</dependency>
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swing-layout</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>TradingInstrument</groupId>
<artifactId>TradingInstrument</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>BrokerOld</groupId>
<artifactId>BrokerOld</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>Utilities</groupId>
<artifactId>Utilities</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>allinonetrade</groupId>
<artifactId>allinonetrade</artifactId>
<version>1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<type>jar</type>
</dependency>
</dependencies>
</project>

Unable to compile and create .avro file from .avsc using Maven

I'm new to Maven and have been looking at tutorials and web for documentation on how to build a .avro from a schema file .avsc. Based on the documentation that on the apache.maven.org site. I have to add the following
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.7.5</version>
</dependency>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.7.5</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
I've added the same into my POM.xml file. I have 2 schema files (.avsc) and following is my directory structure with contents
ProjectDir
src
main
java
avrò
abc.avsc
resources
test
pom.xml
My POM.xml is
<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>org.training</groupId>
<artifactId>TestAvro</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TestAvro</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.basedir>/Users/vsank2/TestAvro</project.basedir>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-compiler</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.7.5</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugin</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I executed the following
mvn clean generate-sources and I get the following output
INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TestAvro 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # TestAvro ---
[INFO] Deleting /Users/vsank2/TestAvro/target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.514s
[INFO] Finished at: Mon Dec 23 16:08:51 PST 2013
[INFO] Final Memory: 2M/81M
[INFO] ------------------------------------------------------------------------
Appreciate any help in this regard. thank you
After a lot of research I found that the problem was completely with my .avsc JSON problem. The "namespace" was totally wrong. As soon as I fixed it. The maven avro plugin created the java class from the schema.
First of it is not the JSON issue. Issue occurred due to addition of tag in t he pom.xml
Points to note :
defines the settings for plugins that will be inherited by child modules in your build. This tag is not required until it is parent POM.
i.e tag is used to manage plugin in child modules.
So no need to add the tag in pom.xml.
If there is any error "Plugin execution not covered by lifecycle configuration" then it is because of the older avro version try to look for latest version it will resolve the issue.
for anyone else that has has the issue.
Also if your configuration is being ignored then moving the configuration block under the plugin section works. It worked for me on the version 1.11.0. I found the fix in this stackoverflow.
Apache Avro maven plugin seems to be ignoring config
Also this github repo is very useful for testing out making a avro file in to java file. there is no custom configuration in it though which you can add yourself.
https://github.com/alexholmes/avro-maven
Also I found this command very useful for debugging f directories do not exist when it is producing the files. It tells you the exact problem.
mvn -X avro:schema

Grails - building modularized project with maven

I am developing grails 2.3.4 application and I'm trying to add maven (3.1.1) for build purposes. I do it so because my project is modularized (2 plugins, 1 app - for now, there will be many more plugins later) and I would like to have tool that supports it (I failed to use Gradle but thats totally another topic). Recently I found some problems that I don't understand and which makes my brain hurt. I would be very grateful for any help about them.
My project structure looks like this:
my_project/
my_project-domain/ (plugin)
pom.xml
my_project-services/ (plugin)
pom.xml
my_project-webap/ (app)
pom.xml
pom.xml
My parent pom.xml:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.app.group</groupId>
<artifactId>myArtifactId</artifactId>
<packaging>pom</packaging>
<version>0.0.2</version>
<name>myArtifactId</name>
<properties>
<grails.version>2.3.4</grails.version>
<h2.version>1.3.170</h2.version>
</properties>
<repositories>
...
</repositories>
<modules>
<module>my_project-domain</module>
<module>my_project-services</module>
<module>my_project-webapp</module>
</modules>
<dependencies>
<!-- MONGODB -->
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>mongodb</artifactId>
<version>1.3.0</version>
<scope>compile</scope>
<type>zip</type>
<exclusions>
<!-- proper spring-core and spring-beans version included by org.grails:grails-plugin-services -->
<exclusion>
<artifactId>spring-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- TOMCAT needed during testing -->
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>tomcat</artifactId>
<version>7.0.47</version>
<scope>provided</scope>
<type>zip</type>
</dependency>
<!-- without h2 TOMCAT throws DataSource errors -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>test</scope>
</dependency>
<!-- GRAILS dependencies-->
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-plugin-async</artifactId>
<version>${grails.version}</version>
</dependency>
...
</dependencies>
<build>
<pluginManagement/>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
...
</plugin>
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>${grails.version}</version>
<configuration>
<fork>true</fork>
<!-- for debugging <forkDebug>true</forkDebug> -->
</configuration>
<extensions>true</extensions>
...
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>tools</id>
...
</profile>
</profiles>
</project>
Sample child pom.xml:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my.app.group</groupId>
<artifactId>myArtifactId</artifactId>
<version>0.0.2</version>
<relativePath>..</relativePath>
</parent>
<groupId>my.app.group</groupId>
<artifactId>my_project-services</artifactId>
<packaging>grails-plugin</packaging>
<version>0.0.2</version>
<name>my_project-services</name>
<description>my_project-services</description>
<dependencies>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>rest</artifactId>
<version>0.8</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
</dependencies>
</project>
I can execute integration tests trough:
mvn test - (from parent dir or child dirs) - which executes only unit tests
grails:test-app - (from child dir) - which executes unit and integration tests
mvn grails:test-app - (only from child dir) which executes unit and integration tests - but it executes them two times instead of one (u,i and then once more u,i)
mvn grails:execute -Dcommand=test-app - (only from child dir) - which executes unit and integration tests in the right amount (u,i) BUT during integration tests some of them suddenly start fail(!!!!) It just blows my mind why..
So, if there is anybody who tried to mix grails 2.3, maybe you have some information about:
how can I configure maven to be able to run mvn grails:test-app from parent pom, not to have such result:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] myArtifactId
[INFO] my_project-domain
[INFO] my_project-services
[INFO] my_project-webapp
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myArtifactId 0.0.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- grails-maven-plugin:2.3.4:test-app (default-cli) # myArtifactId ---
|Loading Grails 2.3.4
|Configuring classpath
|Running pre-compiled script
.
|Environment set to test
.......
|Application metadata not found, please run: grails upgrade
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] myArtifactId ..................................... FAILURE [7.116s]
[INFO] my_project-domain ................................ SKIPPED
[INFO] my_project-services .............................. SKIPPED
[INFO] my_project-webapp ................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
why integration tests executed by mvn grails:test-app pass and by mvn grails:exec -Dcommand=tests-app fail and how to fix it? I would need exec command for some specific purposes and I want to be able to rely on it. It's my biggest problem, I totally don't understand what could be it's cause
why mvn grails:tests-app results in double tests execution?
why I need to add h2 dependency for tomcat? In my dataSources I have only mongodb configuration and I would like to stick only to it and not see below error every time I execute integration tests:
|Completed 8 unit tests, 0 failed in 0m 2s
........pool.ConnectionPool Unable to create initial connections of pool.
java.sql.SQLException: org.h2.Driver
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
...
Caused by: java.lang.ClassNotFoundException: org.h2.Driver
at org.grails.launcher.RootLoader.findClass(RootLoader.java:147)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at org.grails.launcher.RootLoader.loadClass(RootLoader.java:119)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:246)
... 331 more
........
|Running 4 integration tests...
Thanks for everybody who got so far and is still reading - no matter if you can help or not:)
Tom

Could not resolve dependencies for project from workspace

Hi I have a problem with maven. I want to run my app but when I am typing "clean install jetty:run" I am getting this error:
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 frontend 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for laud.b2b:logic:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.585s
[INFO] Finished at: Sat Jul 13 20:17:27 CEST 2013
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Frontend: Could not resolve dependencies for project laud.b2b:Frontend:war:0.0.1-SNAPSHOT: Failure to find laud.b2b:logic:jar:0.0.1-SNAPSHOT in http://maven.vaadin.com/vaadin-addons was cached in the local repository, resolution will not be reattempted until the update interval of vaadin-addons has elapsed or updates are forced -> [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/DependencyResolutionException
"logic" is a second project in my workspace.
I don`t know what to do to resolve this error. I've searched whole internet and I can do nothing with it...
My pom.xml from Frontend project:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>laud.b2b-root</artifactId>
<groupId>laud.b2b</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>laud.b2b</groupId>
<artifactId>Frontend</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>frontend</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>7.1.0</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<repository>
<id>vaadin-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>vaadin-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>${vaadin.version}</version>
</dependency>
<!-- Needed when using the widgetset optimizer (custom ConnectorBundleLoaderFactory).
For widgetset compilation, vaadin-client-compiler is automatically added
on the compilation classpath by vaadin-maven-plugin so normally there is
no need for an explicit dependency. -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<version>${vaadin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<version>${vaadin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-push</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>laud.b2b</groupId>
<artifactId>logic</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>ru.xpoft.vaadin</groupId>
<artifactId>spring-vaadin-integration</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>compile-widgetset</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- As we are doing "inplace" GWT compilation, ensure the widgetset -->
<!-- directory is cleaned properly -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/VAADIN/widgetsets</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.plugin.version}</version>
<configuration>
<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
<!-- <runTarget>mobilemail</runTarget> -->
<!-- We are doing "inplace" but into subdir VAADIN/widgetsets. This
way compatible with Vaadin eclipse plugin. -->
<webappDirectory>${basedir}/src/main/webapp/VAADIN/widgetsets</webappDirectory>
<hostedWebapp>${basedir}/src/main/webapp/VAADIN/widgetsets</hostedWebapp>
<noServer>true</noServer>
<!-- Remove draftCompile when project is ready -->
<draftCompile>false</draftCompile>
<compileReport>true</compileReport>
<style>OBF</style>
<strict>true</strict>
<runTarget>http://localhost:8080/</runTarget>
</configuration>
<executions>
<execution>
<configuration></configuration>
<goals>
<goal>clean</goal>
<goal>resources</goal>
<goal>update-theme</goal>
<goal>update-widgetset</goal>
<goal>compile-theme</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<scanIntervalSeconds>3</scanIntervalSeconds>
</configuration>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<versionRange>[7.1.0,)</versionRange>
<goals>
<goal>resources</goal>
<goal>update-widgetset</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
(AD2)
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 frontend 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # Frontend ---
[INFO] Deleting C:\Users\mateu\git\LPMavenProblem\laud\laud.b2b-root\Frontend\target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # Frontend ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\mateu\git\LPMavenProblem\laud\laud.b2b-root\Frontend\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # Frontend ---
[INFO] Compiling 2 source files to C:\Users\mateu\git\LPMavenProblem\laud\laud.b2b-root\Frontend\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
C:\Program Files (x86)\Java\jre7\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.744s
[INFO] Finished at: Sat Jul 13 21:13:52 CEST 2013
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project Frontend: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files (x86)\Java\jre7\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [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
Most probably you haven't installed all the dependencies you need to build the frontend artifact. If frontend depends on laud.b2b.logic, you must first install this artifact to your local repository before you can build artifacts that depend on it, i.e.:
Go to the logic source tree and execute mvn install
Then go to the frontend and try the build process again
Maybe it's a good idea to create a root pom.xml for all sub-projects and specify them as modules, then start the build process from the new root project. Maven will compile and install them in the correct order.
References:
Multi-module projects in Maven

Resources