Finding the root directory of a multi module maven reactor project

前端 未结 13 1577
庸人自扰
庸人自扰 2020-12-02 11:11

I want to use the maven-dependency-plugin to copy artifacts from all sub-modules of my multi-module project to a directory that is relative to the root directory of the enti

13条回答
  •  臣服心动
    2020-12-02 11:28

    so that: somewhere in properties of some parent Project I've the file which i need to relate later, what's why i need absolute path on it everywhere. So, i get it with help of groovy:

        
     import java.io.File; 
            String p =project.properties['env-properties-file']; 
            File f = new File(p); 
            if (!f.exists()) 
            { 
               f = new File("../" + p); 
              if (!f.exists()) 
              { 
                 f = new File("../../" + p); 
              } 
            } 
            // setting path together with file name in variable xyz_format 
            project.properties['xyz_format'] =f.getAbsolutePath() 
                                + File.separator 
                                + "abc_format.xml"; 
    
       
    

    and then:

      
         http://localhost:8081/snapshots
         http://localhost:8081/releases
         jdbc:oracle:thin:sonar/sonar@localhost/XE
         sonar
          ${xyz_format}  <---- here is it!
        
    

    it works!

提交回复
热议问题