Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在gradle中的jar命令中使用include和exclude并不包括所需的所有类_Java_Build.gradle - Fatal编程技术网

Java 在gradle中的jar命令中使用include和exclude并不包括所需的所有类

Java 在gradle中的jar命令中使用include和exclude并不包括所需的所有类,java,build.gradle,Java,Build.gradle,我需要从项目中的java类子集创建一个jar。 我有3个任务:复制、编译、Jar 复制和编译任务工作正常。 以下为参考资料: 1.将文件复制到编译jar所需的目录。此目录中还需要其他文件,这些文件在编译时需要,但不包括在jar文件中 task copyCoreSharedFiles(type: Copy) { includeEmptyDirs = false from ('src/java/com/') (List of includes and exc

我需要从项目中的java类子集创建一个jar。 我有3个任务:复制、编译、Jar 复制和编译任务工作正常。 以下为参考资料: 1.将文件复制到编译jar所需的目录。此目录中还需要其他文件,这些文件在编译时需要,但不包括在jar文件中

 task copyCoreSharedFiles(type: Copy) {
        includeEmptyDirs = false
        from ('src/java/com/')
    (List of includes and excludes) 
        into  rootProject.rootDir.getAbsolutePath() + "/target" +"/coreshared"
        println 'Copied core-shared files into directory'   
    }
2. Compile the java files and stored to another directory


 task compileCoreShareJar(type: JavaCompile) {
        source = file('target/coreshared')
        destinationDir = file('target/buildtmp/core')
        classpath = configurations.compile
        println 'Compiled core-shared files into directory' 
    }
我在处理所有类文件时遇到问题。 下面是任务

task jarCoreShareClassFiles(type: Jar) {
    includeEmptyDirs = false
    archiveName = "core-shared-SNAPSHOT.jar"
    destinationDir = file("$rootDir/target/lib/")
    from file('target/buildtmp/core')
    include('**/com/common/*')
    include('**/com/javaserver/*')
    exclude('**/com/javaserver/dock/transaction/PrintTransaction.class')

    println 'Jar core-shared files into directory'
}
我需要包括和排除特定的目录和文件。 当我使用include“***/com/common/*”时,它包括公共目录文件,但不包括公共目录下的本地子目录。 它根本不包括javaserver目录


如何在jar命令中使用include和exclude?

该*模式与子目录不匹配。要递归到子目录中,您可以使用**。

很好,*只匹配一个级别。它不会进入子目录。好的……很高兴知道!这就是我所需要知道的…我知道了。请添加您的评论作为答案,以便我可以结束此操作。