Search code examples
javaeclipsemavenm2eclipsem2e

Single command to build all Eclipse maven projects in current workspace?


Does anyone know any simple yet effective way to build all Maven projects in current workspace, for example, maven clean install for each such project.

Is it for example possible to select multiple projects and use something similar to ${project_loc} or get a popup with possible projects to use for the run configuration? Or any other way?

I'm using Eclipse Juno.


Solution

  • Can you give them all a parent pom.xml and then mvn compile the parent pom.xml?

    Look for project inheritance here.

    If you can specify relative paths, this shouldn't be too hard. Create a new maven project with a pom.xml something like:

    <?xml version="1.0"?>
    <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.example</groupId>
        <artifactId>parent-app</artifactId>
        <packaging>pom</packaging>
        <version>1</version>
        <modules>
            <module>../project1</module>
            <module>../project2</module>
        </modules>
    </project>
    

    Delete the projects from your Eclipse workspace (but not the file system) and then import the parent maven project. Now you can:

    Run As... > Maven build > clean compile (as Goals)

    and it should clean and compile all the projects.