1

I have a legacy JAVA project which uses ant for builds. Since jar dependency management in this project is really tedious, I am planning to integrate maven.

I am trying to use maven only for dependency management and keep using ant for builds. I am contemplating to produce a single jar using maven which will contain all the dependencies and then I will include this single jar in classpath of my app.

I know this might not be the best approach but is it possible to do this? What might be a better approach?

tryingToLearn
  • 10,691
  • 12
  • 80
  • 114

1 Answers1

2

I would create a pom.xml file (with all the required fields, like groupId, artifactId ...) add all the dependencies to this pom, and add maven assembly plugin to this pom. execute mvm assembly:single command. Your jar with all the dependencies will be created.

<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>    
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
    </plugin>
  </plugins>
</build>
miskender
  • 7,460
  • 1
  • 19
  • 23
  • @theLearner If you don't add dependency to your app in this pom, it won't contain it. Think of it as a new project without any source code. But in this pom xml you have to define groupId artifactId like any maven pom. – miskender Feb 15 '18 at 03:23
  • You have given a perfect answer to my imperfect question. I am accepting this answer and posted my problem in a different sense/context at: https://stackoverflow.com/questions/48799725/migrating-legacy-ant-project-to-maven-gradle. Please have a look , if you could answer that as well. – tryingToLearn Feb 15 '18 at 04:01