0

.m2/repositoryインストール フェーズの前に、リポジトリ全体 ( ) のコンテンツを削除したいと思います。もちろん、手動でやりたくないので、魔法を行うプラグインを探しています。これまでのところmaven-clean-plugin、次のように使用しようとしています。

<build>
      <sourceDirectory>src/</sourceDirectory>
      <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <source>${jdk.version}</source>
               <target>${jdk.version}</target>
            </configuration>
        </plugin>  
        <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
        <filesets>
                  <fileset>
                      <directory>${settings.localRepository}/</directory>
                      <includes>
                          <include>**/*</include>
                      </includes>
                  </fileset>
        </filesets>
        </configuration>
        <executions>
          <execution>
            <id>auto-clean</id>
            <phase>install</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      </plugins>
   </build>

これにより、新しいアーティファクトをダウンロードする前にリポジトリ全体が消去され、最終的にtargetモジュールからフォルダーが削除されると予想されます。フォルダーの削除はtarget機能しますが、リポジトリの消去は機能しません。リポジトリを一掃しますが、maven は必要なアーティファクトが欠落していると不平を言うため、コンパイルは失敗し、次のようなエラーが返されます。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.3:resources (default-resources) on project com.google.protobuf: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.3:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.3 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.3 -> [Help 1]

解決にかなり近づいた気がします。おそらく、プラグインのパラメータ タグを微調整する必要があるだけです。

誰かアイデアを教えてください。

4

1 に答える 1

5

ローカル リポジトリ全体をクリーンアップすると、maven が必要とし、クリーン ランの前にダウンロードされたすべてのプラグインも削除されます。プロジェクトの依存関係である jar のみを削除するには、依存関係プラグインを使用する必要があります。

mvn dependency:purge-local-repository

pom では、次のように使用できます。

  <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <version>2.7</version> 
    <executions> 
      <execution> 
        <id>purge-local-dependencies</id> 
        <phase>clean</phase> 
        <goals> 
          <goal>purge-local-repository</goal> 
        </goals> 
        <configuration> 
          <resolutionFuzziness>groupId</resolutionFuzziness> 
          <includes> 
            <include>org.ambraproject</include> 
          </includes> 
        </configuration> 
      </execution> 
    </executions> 
  </plugin> 
于 2016-07-28T08:36:36.550 に答える