在基于 Dist::Zilla 的發行版中,我想要一些僅用于測驗但不安裝的檔案。這些是運行時不需要的模型庫。
我怎么做?
uj5u.com熱心網友回復:
CPAN 發行版從不安裝t和xt目錄。您可以將測驗和模擬庫放入t.
以我的模塊MooseX::LocalAttribute 為例。在 dist中,有 a t/、 at/lib和 an xt/。
如果您將其安裝cpanm -l到本地 lib 目錄中,您將看到沒有安裝任何測驗。這會自動發生。這就是 CPAN 的作業原理。
$ cpanm -l mylib MooseX::LocalAttribute
--> Working on MooseX::LocalAttribute
Fetching http://www.cpan.org/authors/id/S/SI/SIMBABQUE/MooseX-LocalAttribute-0.05.tar.gz ... OK
Configuring MooseX-LocalAttribute-0.05 ... OK
Building and testing MooseX-LocalAttribute-0.05 ... OK
Successfully installed MooseX-LocalAttribute-0.05
1 distribution installed
$ tree mylib
mylib
├── lib
│ └── perl5
│ ├── MooseX
│ │ └── LocalAttribute.pm
│ └── x86_64-linux
│ ├── auto
│ │ └── MooseX
│ │ └── LocalAttribute
│ └── perllocal.pod
└── man
└── man3
└── MooseX::LocalAttribute.3
9 directories, 3 files
請注意,只要東西在t/lib(或t/實際上在 下的任何位置),您就不必從 PAUSE 索引器中隱藏包名稱。它足夠聰明,找不到它。
uj5u.com熱心網友回復:
我誤解了這個問題。此答案適用于以下問題:
如何從基于 Dist::Zilla 的發行版中排除檔案,使它們根本不發貨?
您可能正在使用GatherDir或Git::GatherDir插件來構建您的包。它們都有一個選項exclude_filename,您可以在 dist.ini 中設定為不在包中包含檔案。
一種常見的模式是排除自動生成的檔案,例如LICENSE或META.json,然后稍后使用另一個插件添加它們。但是您不必這樣做,您可以完全排除檔案。
一個很好的例子是 URI 分布。在metacpan 上,它不包含捆綁包中的任何文本檔案。但是如果你查看github 上的存盤庫,你可以看到有各種 .txt 檔案,例如rfc2396.txt。dist.ini包含以下幾行。
[Git::GatherDir]
exclude_filename = LICENSE
exclude_filename = README.md
exclude_filename = draft-duerst-iri-bis.txt
exclude_filename = rfc2396.txt
exclude_filename = rfc3986.txt
exclude_filename = rfc3987.txt
如前所述,LICENSE和README.md檔案仍將出現在最終包中,因為它們稍后會通過@Git::VersionManager添加。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/504234.html
標籤:perl 盘 dist-zilla
