Can I add jars to maven 2 build classpath without installing them?

前端 未结 24 2576
萌比男神i
萌比男神i 2020-11-22 01:41

Maven2 is driving me crazy during the experimentation / quick and dirty mock-up phase of development.

I have a pom.xml file that defines the dependenc

24条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 01:54

    Even though it does not exactly fit to your problem, I'll drop this here. My requirements were:

    1. Jars that can not be found in an online maven repository should be in the SVN.
    2. If one developer adds another library, the other developers should not be bothered with manually installing them.
    3. The IDE (NetBeans in my case) should be able find the sources and javadocs to provide autocompletion and help.

    Let's talk about (3) first: Just having the jars in a folder and somehow merging them into the final jar will not work for here, since the IDE will not understand this. This means all libraries have to be installed properly. However, I dont want to have everyone installing it using "mvn install-file".

    In my project I needed metawidget. Here we go:

    1. Create a new maven project (name it "shared-libs" or something like that).
    2. Download metawidget and extract the zip into src/main/lib.
    3. The folder doc/api contains the javadocs. Create a zip of the content (doc/api/api.zip).
    4. Modify the pom like this
    5. Build the project and the library will be installed.
    6. Add the library as a dependency to your project, or (if you added the dependency in the shared-libs project) add shared-libs as dependency to get all libraries at once.

    Every time you have a new library, just add a new execution and tell everyone to build the project again (you can improve this process with project hierachies).

提交回复
热议问题