2011-02-10 8 views
2

mvn eclipse:eclipseコマンドを使用して.project.classpathを生成しています。mvn eclipseを使って.classpathにカスタム行を追加する方法はありますか:eclipse?

しかし、何らかの理由で、.classpathファイルに1行追加したいと考えています。 pom.xmlにこれを達成するための設定がありますか?

<additionalConfig>は、.classpathの内容を消去するため、使用できません。

私はmaven 3.0.2とmaven-eclipse-plugin 2.8を使用しています。

答えて

4

その行が何であるかによって異なります。それがソースフォルダだ場合、 generate-sources前 ライフサイクル・フェーズに add a source folderbuildhelper-maven-pluginを使用し、これは 自動的 Eclipseプラグインによってピックアップされます

  1. それはクラスパスコンテナの場合は、あなた は、あなたが(target/classestarget/test-classesから別のものに)出力フォルダを変更したい場合は、Mavenのビルド構成でそれらを変更classpathContainers パラメータ
  2. を使用することができます。

    <build> 
        <!-- replace "target" --> 
        <directory>somedir</directory> 
        <!-- replace "target/classes" --> 
        <outputDirectory>anotherdir</outputDirectory> 
        <!-- replace "target/test-classes" --> 
        <testOutputDirectory>yetanotherdir</testOutputDirectory> 
    </build> 
    

    あなたは独立して、これら3つのそれぞれを構成することができ、変更はEclipseプラグインによってピックアップされますが、referenによって通常directory(内部outputDirectorytestOutputDirectoryを置くために良い習慣を検討しています${project.build.directory})をcing、そうでなければ、(それが${project.build.directory}をクリーン)mvn cleanのような標準機能を破る:

    <build> 
        <directory>bin</directory> 
        <outputDirectory>${project.build.directory}/main-classes 
        </outputDirectory> 
        <!-- this config will replace "target" with "bin", 
         compile src/main/java to "bin/main-classes" 
         and compile src/test/java to "bin/test-classes" 
         (because the default config for <testOutputDirectory> is 
         ${project.build.directory}/test-classes) 
        --> 
    </build> 
    

参考:


更新:あなたのケースでは、私が唯一の可能な解決策は、プログラム.classpathファイルを編集することであると思います。 (this versionを使用)

  • で短いグルーヴィーなスクリプト(インラインを書く

    1. <profile>という名前の日食(または何でも)を定義
    2. gmaven pluginの実行を定義します。私はおそらくだろうと、このようなものですpomまたはexternal)。クラスパスコンテナの.classpathファイルをチェックし、欠けている場合は追加します(ライフサイクルフェーズに実行をバインドします。generate-resources
    3. は設定profile activation<file><exists>${project.basedir}/.classpath</exists></file>に、あなたはそれが)Eclipseプロジェクトに積極的になりたいので

    この解決策の問題:eclipse:eclipseがゴールではなく、段階なので、することはできません

    mvn eclipse:eclipse # two separate executions 
    mvn generate-resources # here, profile will be active 
    

    または多分これも動作します:あなたはこのような何かをする必要がありますので、これを自動的に実行

    mvn -Peclipse eclipse:eclipse generate-resources 
    
  • +0

    3番目の選択肢です:)実際、私の行は特定の情報( 'output'情報など)を持つ' 'なので、これらのプラグインは適切な設定を持っていないようです... – romaintaz

    +0

    @romaintaz私の更新を参照してください –

    +0

    @Seanありがとう、私は実際にはかなりMavenを知っていますが、これは私が欲しいものではありません。完全な問題を理解したい場合は、私の他の質問をここでご覧ください:http://stackoverflow.com/questions/4956245/how-to-manage-linked-resources-in-eclipse-for-correct-tomcat-deployment – romaintaz

    関連する問題