2011-10-26 39 views
30

Trong những gì phải là một sự xuất hiện phổ biến, tôi cần phải bao gồm một thư mục trống trong một hội đồng. Trong trường hợp của tôi, nó là nhật ký /.Làm cách nào để bao gồm một thư mục trống trong một cụm maven?

tôi đã cố gắng biến thể khác nhau trong mô tả lắp ráp như:

<fileSet> 
    <directory>${basedir}/target</directory> 
    <includes> 
    <include>doesntexist</include> 
    </includes> 
    <outputDirectory>/logs</outputDirectory> 
    <fileMode>0644</fileMode> 
</fileSet> 

và thư mục chỉ được cắt tỉa.

tôi đã cố gắng để loại trừ là tốt, nhưng điều đó vẫn bao gồm rất nhiều thứ:

<fileSet> 
    <directory>${basedir}/target</directory> 
    <excludes> 
    <exclude>*</exclude> 
    </excludes> 
    <outputDirectory>/logs</outputDirectory> 
    <fileMode>0644</fileMode> 
</fileSet> 

Trả lời

19

Courtesy, this SO answer và với một số thử và sai, sau một dường như làm việc cho tôi ...

<fileSet> 
    <directory>src/main/assembly</directory> 
    <outputDirectory>/logs</outputDirectory> 
    <excludes> 
    <exclude>*</exclude> 
    </excludes> 
</fileSet> 

Mấu chốt có vẻ là để đảm bảo rằng <directory> thẻ chỉ định hợp lệ/hiện thư mục, mà không có bất kỳ thư mục con.

+5

Nếu thư mục của bạn chứa các thư mục, bạn có thể loại trừ tất cả chúng (và tất cả các tệp) bằng cách sử dụng ' **/*'. – Leukipp

+0

Giải pháp này không hiệu quả đối với tôi. Christopher làm việc tốt. – BlackEye

40

luôn này làm việc cho tôi:

<fileSets> 
    <fileSet> 
    <directory>.</directory> 
    <outputDirectory>logs</outputDirectory> 
    <excludes> 
     <exclude>*/**</exclude> 
    </excludes> 
    </fileSet> 
</fileSets> 
+0

cảm ơn vì mẫu hữu ích của anh ấy. Ngoài ra, nếu thư mục nhập 'của bạn' dựa vào thư mục con xây dựng, đừng quên chuyển tiếp thư mục trống ở bước tài nguyên: cf.https: //stackoverflow.com/questions/2605747/maven-how-to-include- thư mục trống – boly38

1
<fileSets> 
    <fileSet> 
     <directory>./EMPTY_DIRECTORY_NAME</directory> 
     <outputDirectory>/REQUIRED_DIRECTORY_NAME in Assembly </outputDirectory> 
     <excludes> 
      <exclude>*/**</exclude> 
     </excludes> 
    </fileSet> 
</fileSets> 

ví dụ

<fileSets> 
    <fileSet> 
     <directory>./Logs</directory> 
     <outputDirectory>/Feed</outputDirectory> 
     <excludes> 
      <exclude>*/**</exclude> 
     </excludes> 
    </fileSet> 
</fileSets> 

Trong trường hợp này mặc dù có một số nội dung trong thư mục Nhật ký, nó sẽ không được bao gồm trong tập hợp nhị phân trong thư mục Nguồn cấp dữ liệu.

Các vấn đề liên quan