2

What is maven equivalent for gradle's one-liner to include all jars from lib(s) folder? i.e. :

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

I have a set of project to mavenize, and for a average project with ~50 jar in lib folder, it takes at least half a day for thorough searching on http://mvnrepository.com/ , guessing versions and jar dependencies looking inside jar etc work to solve technical debt of jar hell.

The problem is old, and as of July 2017, one can find
- How to include system dependencies in war built using maven
- How to add local jar files in maven project?
listing similar answers with their limitations.

New for me were plugins
- addjars-maven-plugin, now dead at https://github.com/kahing/addjars-maven-plugin
- non-maven-jar-maven-plugin at https://github.com/stephenc/non-maven-jar-maven-plugin

Thinking over again, the first step to mavenize a project should be to let compiler use existing jars an focus on code, not on dependencies (that often has jar put there just for a case, or copied in bulk)

    <!-- THIS DOES NOT WORK -->
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <includes>
                <include>lib/*.jar</include>
            </includes>
        </configuration>
    </plugin>
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
  • The second best solution is to use non-maven-jar-maven-plugin of Stephen Collony best solution would be to upload those files into a repository manager and consume them from there cause jar files do not belong into version control... – khmarbaise Jul 25 '17 at 16:09
  • Researching further there is possibility for a brute force solution to try https://stackoverflow.com/questions/3410548/maven-add-a-folder-or-jar-file-into-current-classpath/45308293#45308293 – Paul Verest Jul 25 '17 at 16:30

0 Answers0