Maven and eclipse: a reliable way to add non-Maven or external jars to a project?

You can use maven to install files from a project\lib folder to the local repo with the maven-install-plugin as below. I have done this before with JDBC drivers. You might have to create a separate pom for it and execute it with mvn -f installdeps.pom or something like that.

If you can get it to play nice and bind with a lifecycle like validate or something, then you can use the m2e plugin with Eclipse and it just might play nice and read dependencies straight from the pom.xml and install the jars as needed to the local repo.

    <plugin>
        <!-- We dont want children attempting to install these jars to the repo. -->
        <inherited>false</inherited>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <executions>
            <execution>
                <id>Microsoft JDBC Driver File 1</id>
                <phase>install</phase>
                <goals>
                    <goal>install-file</goal>
                </goals>
                <configuration>
                    <file>lib/sqljdbc4.jar</file>
                    <groupId>com.microsoft</groupId>
                    <artifactId>microsoft-jdbc-driver</artifactId>
                    <version>4.0</version>
                    <packaging>jar</packaging>
                </configuration>
            </execution>
            <execution>
                <id>ojdbc5</id>
                <phase>install</phase>
                <goals>
                    <goal>install-file</goal>
                </goals>
                <configuration>
                    <file>lib/ojdbc5.jar</file>
                    <groupId>com.oracle</groupId>
                    <artifactId>ojdbc5</artifactId>
                    <version>11.1.2</version>
                    <packaging>jar</packaging>
                </configuration>
            </execution>
        </executions>
    </plugin>

1) you can use system scope dependency

    <dependency>
        <groupId>test</groupId>
        <artifactId>x</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${basedir}/lib/x.jar</systemPath>
    </dependency>

2) you can copy your x.jar to local maven repository as

repository/test/x/1.0/x-1.0.jar

and add a dependency as

    <dependency>
        <groupId>test</groupId>
        <artifactId>x</artifactId>
        <version>1.0</version>
    </dependency>