Grails - building modularized project with maven - 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

Related

Creating a multi module project with maven spring and kotlin get unresolved reference

I am trying to build a multi module maven project with kotlin and spring. I get an error when the kotlin-maven-plugin runs the compile phase.
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # starter ---
[INFO] Deleting /Users/pnts/IdeaProjects/getyour/base/starter/target
[INFO]
[INFO] --- git-commit-id-plugin:2.2.6:revision (default) # starter ---
[INFO]
[INFO] --- git-commit-id-plugin:2.2.6:revision (get-the-git-infos) # starter ---
[INFO]
[INFO] --- kotlin-maven-plugin:1.3.41:compile (compile) # starter ---
[INFO] Applied plugin: 'spring'
[ERROR] /Users/pnts/IdeaProjects/getyour/base/starter/src/main/kotlin/org/getyour/webdesign/PlainStarter.kt: (6, 9) Unresolved reference: WebsiteEntryPoint
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for parent 0.0.1-SNAPSHOT:
[INFO]
[INFO] parent ............................................. SUCCESS [ 1.178 s]
[INFO] common ............................................. SUCCESS [ 0.021 s]
[INFO] platform-api ....................................... SUCCESS [ 4.238 s]
[INFO] platform-core ...................................... SUCCESS [ 0.215 s]
[INFO] platform-bom ....................................... SUCCESS [ 0.012 s]
[INFO] platform-parent .................................... SUCCESS [ 0.061 s]
[INFO] starter ............................................ FAILURE [ 0.343 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.399 s
[INFO] Finished at: 2019-09-27T08:57:04+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.3.41:compile (compile) on project starter: Compilation failure
[ERROR] /Users/pnts/IdeaProjects/getyour/base/starter/src/main/kotlin/org/getyour/webdesign/PlainStarter.kt:[6,9] Unresolved reference: WebsiteEntryPoint
[ERROR]
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :starter
The funny thing is when I clean my build with "mvn clean" and run the project it compiles and run the spring application.
Spring starts normal
I dont know what causes this issue. Maybe I am missing something.
Here are my poms and my project structure. Hope somebody can help me with this.
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/>
</parent>
<version>0.0.1-SNAPSHOT</version>
<artifactId>parent</artifactId>
<groupId>org.getyour.webdesign</groupId>
<packaging>pom</packaging>
<modules>
<module>common</module>
<module>starter</module>
</modules>
<!-- properties -->
<properties>
<kotlin.version>1.3.41</kotlin.version>
<spring.boot.version>2.1.8.RELEASE</spring.boot.version>
<java.version>1.8</java.version>
<main.class>org.getyour.webdesign.WebsiteEntryPoint</main.class>
</properties>
<!-- repositories -->
<repositories>
<repository>
<id>maven-central</id>
<url>http://central.maven.org/maven2/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- kotlin spring compiler plugin -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<mainClass>${main.class}</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals><goal>compile</goal></goals>
<phase>process-sources</phase>
</execution>
<execution>
<id>test-compile</id>
<goals><goal>test-compile</goal></goals>
<phase>process-test-sources</phase>
</execution>
</executions>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.6</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<prefix />
<verbose>false</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
<format>properties</format>
<gitDescribe>
<skip>false</skip>
<always>false</always>
<dirty>-dirty</dirty>
</gitDescribe>
</configuration>
</plugin>
</plugins>
</build>
</project>
starter 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parent</artifactId>
<groupId>org.getyour.webdesign</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<version>0.0.1-SNAPSHOT</version>
<artifactId>starter</artifactId>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.getyour.webdesign</groupId>
<artifactId>platform-bom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.getyour.webdesign</groupId>
<artifactId>platform-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
</dependencies>
</project>
WebsiteEntryPoint.kt
package org.getyour.webdesign
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
/**
* Start class of the application
*
* #author p.tsivelekidis
* Created by p.tsivelekidis on 2019-09-20
*/
#SpringBootApplication
class WebsiteEntryPoint {
companion object {
fun main(args: Array<String>) {
runApplication<WebsiteEntryPoint>(*args)
println("Hello!")
}
}
}
PlainStarter.kt
package org.getyour.webdesign
class PlainStarter
fun main(args: Array<String>) {
WebsiteEntryPoint.main(args)
}
Here is my project structure. Notice that when I run the "mvn clean install" command I get this.
project structure after mvn clean install
When I clean my project and just run I get this structure.
project structure after clean and just run project
When I run the mvn clean install it does not create the target classes and I guess for that reason it cant find my WebsiteEntryPoint.
Hope somebody can help me with that. Thanks a lot.
i had the same issue with compiling a kotlin multi module project in intellij.
Command mvn clean install produced the same error with the unresolved dependencies.
As i can see your source directories are named kotlin (as in my project before).
After renaming the source directories in my project to java the problem was solved...

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>

maven sql plugin 0 of 0 SQL statements executed successfully

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).

maven compilation fails because unavailable dependency

I'm trying to run java program with maven but when i compiled using the command mvn -U compile
he shows me the following error
[root#onePK-EFT1 tutorials]# mvn -U compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building onePK Java Tutorials 0.6.0.5
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/com/cisco/onep/libonep-core-rel
/0.6.0.5/libonep-core-rel-0.6.0.5.pom
[WARNING] The POM for com.cisco.onep:libonep-core-rel:jar:0.6.0.5 is missing, no
dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/cisco/onep/libonep-
core-rel/0.6.0.5/libonep-core-rel-0.6.0.5.jar
[INFO] ------------------------------------------------------------------------
INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.517s
[INFO] Finished at: Tue Jul 09 07:28:28 PDT 2013
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project java-tutorials: Could not resolve
dependencies for project com.cisco.onep:java-tutorials:jar:0.6.0.5: Could not find
artifact com.cisco.onep:libonep-core-rel:jar:0.6.0.5 in central
(http://repo.maven.apache.org/maven2) -> [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
and this is 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>com.cisco.onep</groupId>
<artifactId>hello-network-app</artifactId>
<version>0.1-SNAPSHOT</version>
<name>The onePK Hello Network Example Application</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<forkMode>always</forkMode>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.cisco.onep</groupId>
<artifactId>libonep-core-rel</artifactId>
<version>0.6.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.6.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
<developers>
<developer>
<name>onePK Team</name>
<email>onepk-feedback#cisco.com</email>
<organization>Cisco.com</organization>
</developer>
</developers>
I think it's because he can't find libonep-core-rel.jar which i have it included
please any help
The simple solution is to use the appropriate maven repository for the artifacts com.cisco.onep* which are not located in Maven central.
As an immediate solution, but not a recommendation, you can use system dependencies to resolve artifacts on your local filesystem.
As #khmarbaise implied, try to publish those corporate artifacts to your corporate Maven repository (Nexus, Artifactory, Archiva, etc.), even an FTP/HTTP server would do...
Once you publish those corporate artifacts to your "corporate" repository(hopefully it's already in place), you just need a new repository declaration in your Maven POM.

Resources