2012-04-25 10 views
13

jOOQでは、jOOQ code generator with Mavencustom generator strategyを組み合わせて使用​​したい場合があります。これはそのようにすることができます(無関係な部分は除外します)。jOOQコードジェネレータとMavenでカスタム戦略を使用するには?

<plugin> 
    <groupId>org.jooq</groupId> 
    <artifactId>jooq-codegen-maven</artifactId> 
    <version>2.2.2</version> 

    <!-- The plugin should hook into the generate goal --> 
    <executions> 
    <execution> 
     <goals> 
     <goal>generate</goal> 
     </goals> 
    </execution> 
    </executions> 

    <configuration> 
    <generator> 
     <name>org.jooq.util.DefaultGenerator</name> 
     <!-- But the custom strategy is not yet compiled --> 
     <strategy> 
     <name>com.example.MyStrategy</name> 
     </strategy> 
    </generator> 
    </configuration> 
</plugin> 

上記の設定は問題を示しています。 jOOQのコードジェネレータは、ライフサイクルのコンパイル目標の前に行われるMavenライフサイクルの生成目標にフックします。ただし、コードを生成するには、あらかじめコンパイルされたカスタム戦略クラスが必要です。またはClassNotFoundExceptionが得られます。これはどのようにMavenで解決できますか? generateの目標を実行する前に、1つのクラスをコンパイルできますか?

答えて

7

もっと良い解決策は、プロジェクトを2つのモジュールに分割することです。 1つは戦略を含み、残りは残りの部分を含む。モジュールを使用

、あなたは独立した手順で戦略をコンパイルして、プラグインでそのモジュールを使用することができます。

<plugin> 
    <groupId>org.jooq</groupId> 
    <artifactId>jooq-codegen-maven</artifactId> 
    <version>2.2.2</version> 

    ...your config goes here... 

    <dependencies> 
    list your strategy module here 
    </dependencies> 
</plugin> 
関連する問題