2017-10-04 93 views
0

我想使用jsonschema2pojo插件來生成基於模式和json sourceTypes的POJO。每次執行都指定配置。但每次插件報告「必須提供sourceDirectory或sourcePaths之一」。我可以在插件級別(全局)提供配置時運行它。但是,我只能指定一個sourceType。jsonschema2pojo maven插件配置執行不考慮

<build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
      <plugin> 
       <groupId>org.jsonschema2pojo</groupId> 
       <artifactId>jsonschema2pojo-maven-plugin</artifactId> 
       <version>0.5.1</version> 
       <executions> 
        <execution> 
         <id>generate-schema</id> 
         <phase>generate-sources</phase> 
         <goals> 
          <goal>generate</goal> 
         </goals> 
         <configuration> 
          <outputEncoding>${project.build.sourceEncoding}</outputEncoding> 
          <outputDirectory>${project.build.directory}/generated-sources</outputDirectory> 
          <annotationStyle>jackson2</annotationStyle> 
          <generateBuilders>false</generateBuilders> 
          <initializeCollections>true</initializeCollections> 
          <refFragmentPathDelimiters>#/</refFragmentPathDelimiters> 
          <sourceType>jsonschema</sourceType> 
          <targetPackage>com.company.app.integration.sabre.stub.rest</targetPackage> 
          <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory> 
         </configuration> 
        </execution> 
        <execution> 
         <id>generate-json</id> 
         <phase>generate-sources</phase> 
         <goals> 
          <goal>generate</goal> 
         </goals> 
         <configuration> 
          <outputEncoding>${project.build.sourceEncoding}</outputEncoding> 
          <outputDirectory>${project.build.directory}/generated-sources</outputDirectory> 
          <annotationStyle>jackson2</annotationStyle> 
          <generateBuilders>false</generateBuilders> 
          <initializeCollections>true</initializeCollections> 
          <refFragmentPathDelimiters>#/</refFragmentPathDelimiters> 
          <sourceType>json</sourceType> 
          <targetPackage>com.company.app.integration.sabre.stub.rest</targetPackage> 
          <sourceDirectory>${basedir}/src/main/resources/json</sourceDirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

     </plugins> 
    </build> 

有沒有什麼辦法讓插件使用每個目標在執行級別的配置?

插件版本:0.5.1

回答

0

嘗試移動你的配置出來的插件級別,並使用父文件夾($ {BASEDIR}/src目錄/主/資源)作爲sourceDirectory。

這裏的描述同樣的事情,一個老的bug報告: https://github.com/joelittlejohn/jsonschema2pojo/issues/145

+0

感謝您的提示。這隻會照顧子文件夾的包創建。我想有兩個不同的文件夾分別對待jsonschema和json。 – Sandheep

0

TL;博士

當運行從Maven項目生命週期中的「編譯」,插件正在考慮執行配置並按預期工作。


我使用的IntelliJ,並試圖從生成的插件POJO - > jsonschema2pojo - > jsonschema2pojo:在 'Maven項目' 窗口中生成。這是給出了上述錯誤,並沒有採取每次執行配置。

當我從Maven生命週期運行編譯時,它在執行中選擇配置並正在生成指定的文件。

我還不確定這是插件或maven的問題還是它的問題!

相關問題