を使用してディレクトリ構造からいくつかのソースを処理したいのですがSourceDirectorySet
、元のディレクトリ構造を模倣して、ビルド ディレクトリの下に出力を保存したいと考えています。例えば:
src / main / plantuml
+ dir1
+ dir11
+ file.pu
結果は次のようになります。
build / doc / plantuml
+ dir1
+ dir11
+ file.png
どうすればそれを達成できますか?
注意:SourceDirectorySet
ですPatternFilterable
バックグラウンド
janvolck のプラグイン「gradle-plantuml-plugin」 (対応する機能リクエストが既に存在する) を拡張して、構成されたディレクトリの下に出力ファイルを生成するが、元のディレクトリ階層を維持したい。gradle プラグインの現在の実装は、a のすべてのファイルをトラバースしSourceDirectorySet
、ソース ファイルが存在する同じディレクトリに出力ファイルを生成します。
これは私が出すことができる最も近いものです:
// Process directory trees
mySourceDirectorySet.srcDirTrees.each { DirectoryTree d ->
project.logger.debug("Processing srcDirTree " + d.dir
+ "; patterns.excludes: " + d.patterns.excludes
+ "; patterns.includes" + d.patterns.includes)
// Reconstruct a FileTree from the directory tree, as I cannot find
// any means to get the files directly from 'd' (1)
// ... and traverse its files
project.fileTree(dir: d.dir,
excludes: d.patterns.excludes,
includes: d.patterns.includes).each { File f ->
project.logger.info("-- Input file: " + f)
def relPath = d.dir.toURI().relativize(f.parentFile.toURI())
def outputPath = "/myOutputDir/" + relPath
option.setOutputDir(project.file(outputPath))
processFile(f, option);
}
}
残念ながら、このトリックは(1)
機能していないようで、適切な FileTree を再作成できません。
私の訓練されていないグラドルの直感は、このタスクを簡単に達成できるはずだと言っています。私は確かに何かが欠けていますか?