두 프로필이 pom.xml에 있고 첫 번째 프로필 실행 중에 대상 리소스 디렉토리에 추가 한 리소스 파일이 하나 있습니다 (${project.build.outputDirectory}/resources
). 내가해야 할 일은 두 번째 프로필을 실행하는 동안 해당 리소스 파일을 제거하는 것입니다. 대상 디렉토리에서 기존 파일을 제거하거나 삭제할 수있는 방법이 있습니까?pom 파일을 사용하여 대상 디렉토리에서 리소스 파일 제거 또는 삭제
답변
mvn clean
은 target
디렉토리 (및 그에 포함 된 모든 파일)를 제거합니다. 당신의 target
디렉토리에서의 조합을 특정 파일을 제거하려면 다음
excludeDefaultDirectories
전체 디렉토리를 삭제을 중지하고, 무엇을 삭제filesets
은 말할
심판 : 나는 매튜의 observatio에 동의 http://maven.apache.org/plugins/maven-clean-plugin/clean-mojo.html
ns이지만 원래 포스터가 프로파일의 (정상적인) "실행"중에 clean
의 실행을 자동화하는 방법을 묻고 있다는 인상을 받았습니다.
Maven Clean Plugin에 대해 plugin execution을 정의 할 수 있습니다. 일반적으로 clean
에 바인딩되지만 플러그인 실행을 정의하면 clean:clean
(플러그인의 clean
목표)을 lifecycle phase 중 원하는 것으로 바인딩 할 수 있습니다. Maven Clean Plugin의 문서에는 이것을 수행하는 방법에 대한 an example이 있습니다. 설명서에는 an example의 추가 파일이 삭제됩니다. 두 모양을 병합했습니다.
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>some/relative/path</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
해결책이 있습니다 .. !! 참조
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete>
<fileset dir="${project.build.outputDirectory}/resources" includes="*.xml" />
</delete>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
- 위의 답변에 http://maven.apache.org/guides/mini/guide-building-for-different-environments.html
감사합니다. 마지막으로 내가 좋아하는 일에 온 : 당신은 J UST 대상 폴더에일부 디렉토리를 삭제하려면
,이 같은 일부 구조를 만들어야합니다. 예를 들어
이 폴더의 바로 모든 내용을 삭제 :
- 대상/전체 대상 폴더를 삭제 하다며 N 에 허용
- 발전기 외부 apklibs
excludeDefaultDirectories 압축을 풉니 다.
린트 분석 전에 대상 폴더를 정리하는 데 사용했습니다.Apache Maven AntRun Plugin 1.8와
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>Deleting all unnecessary files before lint analysis</id>
<phase>verify</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>target/unpack</directory>
<followSymlinks>false</followSymlinks>
<excludes>
<exclude>*</exclude>
</excludes>
</fileset>
<fileset>
<directory>gen-external-apklibs</directory>
<followSymlinks>false</followSymlinks>
<excludes>
<exclude>*</exclude>
</excludes>
</fileset>
</filesets>
<verbose>true</verbose>
</configuration>
</plugin>
솔루션 :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete
dir="${project.build.outputDirectory}/resources"
includeemptydirs="true"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
내가 출력 디렉토리에서 삭제 된 파일의 몇 필요는, 다음은 나를 위해 잘 일했다.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete file="${project.build.outputDirectory}/appContextLocal.xml" />
<delete
file="${project.build.outputDirectory}/appContextServer.xml" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
은 또한 당신이 어떤 개미 명령을 실행 이제까지 당신이
<tasks> .... </tasks>
사이에 필요한 작업 무엇을 교체하고 작동 할 수 있다는 생각.
http://maven.apache.org/plugins/maven-antrun-plugin/usage.html
- 1. 디렉토리에서 파일 삭제
- 2. 디렉토리에서 .zip 파일 삭제
- 3. MVC 디렉토리에서 파일 삭제
- 4. nodejs를 사용하여 디렉토리에서 fs 파일을 삭제 하시겠습니까?
- 5. 현재 디렉토리에서 파일 제거
- 6. fileinput.py 대상 파일 삭제
- 7. 여러 디렉토리에서 Inode를 통해 파일 삭제
- 8. APK에서 리소스 파일 제거
- 9. Excel 스프레드 시트에없는 파일을 디렉토리에서 삭제
- 10. 설치 디렉토리에서 모든 파일을 제거 하시겠습니까?
- 11. 자리 표시자를 사용하여 파일 제거
- 12. 여러 디렉토리에서 비슷한 이름의 파일 삭제
- 13. PHP 하위 디렉토리에서 파일을 삭제 하시겠습니까?
- 14. make 파일을 사용하여 별도의 디렉토리에서 파일 컴파일
- 15. PHP 디렉토리에서 파일 검색 및 삭제 - 성능
- 16. $ cordovaFileTransfer 로컬 파일 제거/삭제
- 17. 배포 프로젝트 제거 - 파일 삭제 중?
- 18. 리소스 디렉토리에서 파일을 열 수 없습니다.
- 19. 1 분 후에 디렉토리에서 파일 삭제
- 20. Xlib 라이브러리를 사용하여 라인 삭제 또는 제거
- 21. KSH에서만 한 수준의 디렉토리에서 파일 제거
- 22. perl을 사용하여 파일 삭제
- 23. oracle 저장 프로 시저의 디렉토리에서 파일 삭제
- 24. maven war 플러그인을 사용하여 대상 디렉토리에서 파일/디렉토리를 제외하려면 어떻게합니까?
- 25. Maven 대상 디렉토리에서 WebLogic 가리키기
- 26. iOS의 문서 디렉토리에서 파일 저장 및 삭제
- 27. , 파일 삭제 또는 파일 만들기 확인
- 28. PowerShell 명령을 사용하여 파일 또는 폴더 삭제
- 29. FSEvents - 대상 디렉토리에서 변경된 내용을 찾으십시오.
- 30. 소스 디렉토리에서 정적 리소스 읽기
일반적으로, 메이븐에, 당신은 그냥 개미, 그루비 같은 위해 (이 플러그인을 그것을 코딩을 통해, 선언적 솔루션을 선호하는 것 : 당신이 here
가 참조하는 수행 할 수있는 개미 작업
목록 , 등) 할 수 있습니다. –