99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

Gradle指定一組輸入文件

2020-07-24 16:01 更新

在 Gradle 中有一些對象的某些屬性可以接收一組輸入文件.例如,JavaComplile 任務(wù)有一個 source 屬性,它定義了編譯的源文件,你可以設(shè)置這個屬性的值,只要 files() 方法支持. 這意味著你可以使用 File ,String , collection , FileCollection 甚至是使用一個閉合去設(shè)置屬性的值.

例 15.8 指定文件

build.gradle

//使用一個 File 對象設(shè)置源目錄
compile {
    source = file('src/main/java')
}

//使用一個字符路徑設(shè)置源目錄
compile {
    source = 'src/main/java'
}

// 使用一個集合設(shè)置多個源目錄
compile {
    source = ['src/main/java', '../shared/java']
}

// 使用 FileCollection 或者 FileTree 設(shè)置源目錄
compile {
    source = fileTree(dir: 'src/main/java').matching { include 'org/gradle/api/**' }
}

// 使用一個閉合設(shè)置源目錄
compile {
    source = {
        // Use the contents of each zip file in the src dir
        file('src').listFiles().findAll {it.name.endsWith('.zip')}.collect { zipTree(it) }
    }
}

Usually, there is a method with the same name as the property, which appends to the set of files. Again, this method accepts any of the types supported by the files() method.

通常情況下,會有一個方法名和屬性名相同的方法能夠附加一組文件,這個方法接收 files() 方法支持的任何類型的值.

例 15.9 指定文件

build.gradle

compile {
    // 使用字符路徑添加源目錄
    source 'src/main/java', 'src/main/groovy'

    // 使用 File 對象添加源目錄
    source file('../shared/java')

    // 使用閉合添加源目錄
    source { file('src/test/').listFiles() }
}


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號