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

前端 未结 24 2893
萌比男神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

    This is what I have done, it also works around the package issue and it works with checked out code.

    I created a new folder in the project in my case I used repo, but feel free to use src/repo

    In my POM I had a dependency that is not in any public maven repositories

    
        com.dovetail
        zoslog4j
        1.0.1
        runtime
    
    

    I then created the following directories repo/com/dovetail/zoslog4j/1.0.1 and copied the JAR file into that folder.

    I created the following POM file to represent the downloaded file (this step is optional, but it removes a WARNING) and helps the next guy figure out where I got the file to begin with.

    
    
        4.0.0
        com.dovetail
        zoslog4j
        jar
        1.0.1
        z/OS Log4J Appenders
        http://dovetail.com/downloads/misc/index.html
        Apache Log4j Appender for z/OS Logstreams, files, etc.
    
    

    Two optional files I create are the SHA1 checksums for the POM and the JAR to remove the missing checksum warnings.

    shasum -b < repo/com/dovetail/zoslog4j/1.0.1/zoslog4j-1.0.1.jar \
              > repo/com/dovetail/zoslog4j/1.0.1/zoslog4j-1.0.1.jar.sha1
    
    shasum -b < repo/com/dovetail/zoslog4j/1.0.1/zoslog4j-1.0.1.pom \
              > repo/com/dovetail/zoslog4j/1.0.1/zoslog4j-1.0.1.pom.sha1
    

    Finally I add the following fragment to my pom.xml that allows me to refer to the local repository

    
        
            project
            file:///${basedir}/repo
        
    
    

提交回复
热议问题