2010-12-10 14 views
1

私はmaven pom.xmlを解析しようとしています。私はある程度成功しました。しかし、私の問題は私がデフォルト値を得ることができないということです。私は手動でデフォルト値を注入する必要があります。 たとえば、バージョン番号がpom.xmlに指定されていない場合、親バージョンが使用されることは明らかです。 ビルドディレクトリが指定されていない場合は、ターゲットになります。maven jarを使用したmaven pom.xmlの解析

私はこれらのことを自動的に入力するためにどのクラスを使うべきかを知る必要があります。それ以外は、私のために依存グラフを作成したいと思います。解析に使用しているコードは

 Model model = null; 
    FileReader reader = null; 
    MavenXpp3Reader mavenreader = new MavenXpp3Reader(); 
    try { 
     reader = new FileReader(pomfile); 
     model = mavenreader.read(reader); 
     model.setPomFile(pomfile); 

     if (model.getBuild() != null) { 
      // location of output directory basically target 
      if (model.getBuild().getDirectory() == null) { 
      //set the build directory 

      } // location of compiled classes 
      if (model.getBuild().getOutputDirectory() == null) { 
         // set the classes directory 
      } 
     } 
    } catch (FileNotFoundException e) { 
     e.printStackTrace(); 
     throw new RuntimeException("pom file not found " + pomfile); 
    } catch (IOException e) { 
     e.printStackTrace(); 
     throw new RuntimeException("pom file is not accessible " + pomfile); 
    } catch (XmlPullParserException e) { 
     e.printStackTrace(); 
     throw new RuntimeException("unable to parse pom " + pomfile); 
    } catch (NullPointerException nullPointerException) 
     System.out.println("Exception setting build dir "+model.getPackaging()); 

    } finally { 
     if (reader != null) { 
      reader.close(); 
     } 
    } 

ありがとうございます。

答えて

-1

ヘルプのコードを見てください:effective-pomプラグインのゴール、または効果的なPOMとxml-parse結果を実際に使用してください。

関連する問題