0

I have a maven desktop application which contains thirdy-party and my own dependencie projects (Business, Repository and GUI). I want to be able to build the application with the below folder structure:

    App.jar
    AppBusiness.jar
    AppRepository.jar
    AppGUI.jar
    lib(folder)
      - the rest of thirdy-party jars in lib folder
        (hibernate, jackson, drivers, etc..)

Can I do that?

tahan
  • 81
  • 6
josev.junior
  • 409
  • 2
  • 5
  • 13
  • Possible duplicate of [Downloading all maven dependencies to a directory NOT in repository?](https://stackoverflow.com/questions/7908090/downloading-all-maven-dependencies-to-a-directory-not-in-repository) –  Aug 25 '19 at 15:15
  • This sounds like a job for [maven-assembly-plugin](https://maven.apache.org/plugins/maven-assembly-plugin/) which creates an archive (tar.gz, zip etc.) which can be unpackaged and produces the required structure – khmarbaise Aug 25 '19 at 19:28

1 Answers1

1

You can use the maven dependency plugin to copy the dependencies to the chosen directory and then zip/tar it as per need.

  • But I want to copy some dependencies in the lib folder and some others in another folder. – josev.junior Aug 25 '19 at 15:27
  • Assumed you want the project artefacts in target and rest of the dependencies in the lib folder. If we want control on copying specific jars/dependencies the dependency plugin has the configuration to support selecting specific items, see the [example](https://maven.apache.org/plugins-archives/maven-dependency-plugin-2.6/examples/copying-artifacts.html) here. You also can use the [antrun](https://maven.apache.org/plugins/maven-antrun-plugin/tasks/dependencyFilesets.html) to copy things around – Shankhanil Das Aug 25 '19 at 15:39
  • With your link I could copy specific jars to specific paths as I wanted. But I got a new problem: The classpath. Do you have some idea how I can configure it to include my custom path jars? – josev.junior Aug 25 '19 at 17:04
  • Where do you want to set the classpath? If you want maven to manage the dependencies, we don't need to separately copy the jars to a separate folder. If however, we are distributing this, and some other apps to rely on this, options are -
      - set the lib folder in classpath, as well as the dir having application jars e.g. java -cp {path to lib}/* {main class} - If we use an ide simply add the jars folder - if another project is also maven based, multiple [examples](https://maven.apache.org/shared/maven-archiver/examples/classpath.html)
    – Shankhanil Das Aug 25 '19 at 17:33