Skip to content

Instantly share code, notes, and snippets.

@mkscrg
Created June 18, 2012 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkscrg/2950830 to your computer and use it in GitHub Desktop.
Save mkscrg/2950830 to your computer and use it in GitHub Desktop.
A simple multi-module Maven project with which exec-maven-plugin is unusable.
.idea/
*.iml
target/
public final class HelloPrinter {
void printHello() {
System.out.println("Hello world!");
}
}
public final class MyMain {
public static void main(String[] args) {
new HelloPrinter().printHello();
}
}
<?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>exec-multi-module-test</artifactId>
<groupId>com.mkscrg.sandbox</groupId>
<version>1.0</version>
</parent>
<artifactId>module1</artifactId>
</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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>exec-multi-module-test</artifactId>
<groupId>com.mkscrg.sandbox</groupId>
<version>1.0</version>
</parent>
<artifactId>module2</artifactId>
<dependencies>
<dependency>
<groupId>com.mkscrg.sandbox</groupId>
<artifactId>module1</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkscrg.sandbox</groupId>
<artifactId>exec-multi-module-test</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
<module>module2</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
</plugin>
</plugins>
</build>
</project>
#!/usr/bin/env bash
# StackOverflow question: http://stackoverflow.com/questions/11091311/maven-execjava-goal-on-a-multi-module-project
mvn exec:java -Dexec.mainClass=myMain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment