我正在尝试将ANT构建中的任务转换为Gradle:
<target name="index-assets" depends="copy-assets">
<path id="assets.path">
<!-- contexts (and surplus) -->
<dirset id="assets.dirset" dir="assets/" defaultexcludes="yes"/>
<!-- assets -->
<fileset id="assets.fileset" dir="assets/" includes="**" excludes="asset.index" defaultexcludes="yes"/>
</path>
<pathconvert pathsep="${line.separator}" property="assets" refid="assets.path" dirsep="/">
<mapper>
<globmapper from="${basedir}/assets/*" to="*" handledirsep="yes"/>
</mapper>
</pathconvert>
<echo file="assets/asset.index">${assets}</echo>
</target>
<target name="-pre-build" depends="index-assets"/>
Run Code Online (Sandbox Code Playgroud)
我想我还没有完全掌握基本的Gradle概念,但这是我尝试过的:
task indexAssets << {
def assets = file("assets")
def contexts = files(assets)
inputs.file(assets)
outputs.file("assets/assets-gradle.index")
def tree = fileTree(dir: 'assets', include: ['**/*'], exclude: ['**/.svn/**', 'asset.index'])
contexts.collect { relativePath(it) }.sort().each { println it }
tree.collect { relativePath(it) }.sort().each …Run Code Online (Sandbox Code Playgroud) 我正在检索这样的文件
String[] files = assetFiles.list("EngagiaDroid");
Run Code Online (Sandbox Code Playgroud)
我们如何知道它是文件还是目录?
我想遍历Assets文件夹中的目录,然后复制其所有内容。