LoginSignup
0
3

More than 5 years have passed since last update.

Gradleカスタムタスクで複数先にファイルコピーするならProject.copy()が便利

Posted at

GradleScriptでファイルコピーしようとしてCopyTask使ったら、コピー先が複数指定できなくて困ったときに発見したやつ

CopyTask

  • from:into=N:1 でしか書けない
build.gradle
// src/main/resources/*.properties --> $buildDir
task mycopy(type: Copy) {
    from 'src/main/resources'
    into '$buildDir/resources'
    include '*.properties'
}

Project.copy()

  • from:into=N:M も1つのタスクで実行できる
build.gradle
task mycopy {
  // src/main/resources/*.properties --> $buildDir/prop/
  copy {
    from 'src/main/resources'
    into '$buildDir/prop'
    include '*.properties'
  }
  // src/main/resources/*.xml        --> $buildDir/xml/
  copy {
    from 'src/main/resources'
    into '$buildDir/xml'
    include '*.xml'
  }
}

注意

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3