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

前端 未结 24 2934
萌比男神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 02:09

    After having really long discussion with CloudBees guys about properly maven packaging of such kind of JARs, they made an interesting good proposal for a solution:

    Creation of a fake Maven project which attaches a pre-existing JAR as a primary artifact, running into belonged POM install:install-file execution. Here is an example of such kinf of POM:

     
        
            
                org.apache.maven.plugins
                maven-install-plugin
                2.3.1
                
                    
                        image-util-id
                        install
                        
                            install-file
                        
                        
                            ${basedir}/file-you-want-to-include.jar
                            ${project.groupId}
                            ${project.artifactId}
                            ${project.version}
                            jar
                        
                    
                
            
        
    
    

    But in order to implement it, existing project structure should be changed. First, you should have in mind that for each such kind of JAR there should be created different fake Maven project (module). And there should be created a parent Maven project including all sub-modules which are : all JAR wrappers and existing main project. The structure could be :

    root project (this contains the parent POM file includes all sub-modules with module XML element) (POM packaging)

    JAR 1 wrapper Maven child project (POM packaging)

    JAR 2 wrapper Maven child project (POM packaging)

    main existing Maven child project (WAR, JAR, EAR .... packaging)

    When parent running via mvn:install or mvn:packaging is forced and sub-modules will be executed. That could be concerned as a minus here, since project structure should be changed, but offers a non static solution at the end

提交回复
热议问题