Gradle 3.1 copytask error

issue-acknowledged
gradle-3569

(Ankit ) #1

I am seeing an ERROR with I use the copy task with gradle 3.1. Can anyone help here?

Caused by: org.gradle.api.GradleException: Could not add file '/Users/xxxx/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar' to TAR '/Users/ankitsrivastava/xxxxxxxxx/xxxxxx.tar.gz'.
        at org.gradle.api.internal.file.archive.TarCopyAction$StreamAction.visitFile(TarCopyAction.java:97)
        at org.gradle.api.internal.file.archive.TarCopyAction$StreamAction.processFile(TarCopyAction.java:83)
        at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1$1.processFile(NormalizingCopyActionDecorator.java:66)
        at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1$1.processFile(DuplicateHandlingCopyActionDecorator.java:60)
        at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.processFile(CopyFileVisitorImpl.java:60)
        at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.visitFile(CopyFileVisitorImpl.java:44)
        at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl$1.visitFile(AbstractFileTree.java:150)
        at org.gradle.api.internal.file.collections.SingletonFileTree.visit(SingletonFileTree.java:44)
        at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:109)
        at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl.visit(AbstractFileTree.java:141)
        at org.gradle.api.internal.file.CompositeFileTree.visit(CompositeFileTree.java:58)
        at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:37)
        at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:24)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:570)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:572)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:572)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:572)
        at org.gradle.api.internal.file.copy.DefaultCopySpec.walk(DefaultCopySpec.java:380)
        at org.gradle.api.internal.file.copy.CopySpecBackedCopyActionProcessingStream.process(CopySpecBackedCopyActionProcessingStream.java:36)
        at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1.process(DuplicateHandlingCopyActionDecorator.java:44)
        at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1.process(NormalizingCopyActionDecorator.java:57)
        at org.gradle.api.internal.file.archive.TarCopyAction$1.doExecute(TarCopyAction.java:64)
        at org.gradle.api.internal.file.archive.TarCopyAction$1.doExecute(TarCopyAction.java:54)
        at org.gradle.internal.ErroringAction.execute(ErroringAction.java:35)
        at org.gradle.internal.IoActions.withResource(IoActions.java:74)
        at org.gradle.api.internal.file.archive.TarCopyAction.execute(TarCopyAction.java:54)
        at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:53)
        at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator.execute(DuplicateHandlingCopyActionDecorator.java:42)
        at org.gradle.api.internal.file.copy.CopyActionExecuter.execute(CopyActionExecuter.java:38)
        at org.gradle.api.tasks.AbstractCopyTask.copy(AbstractCopyTask.java:94)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:136)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:129)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:118)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:623)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:606)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 17 more
Caused by: java.lang.NullPointerException

My build.gradle is setup:

task configureTar(dependsOn: jar) {
dependsOn rootProject.getTasksByName('assemble', true)
    doLast {
        def externalLibsSpec = copySpec {
            Map<File, String> runtimeLibs = runtimeLibsWithoutProjectLibs()
            from(runtimeLibs.keySet()) {
                into libVendorDirName
                rename { String fileName ->
                    if (fileName.contains('aspectjweaver')) {
                        fileName.replaceAll('(.+)-(.+).jar', '$1.jar')
                    }
                    else if  (fileName.contains('jolokia')) {
                        fileName.replaceAll('(.+)-(.+)-(.+)\\.jar', '$1.jar')
                    }
                }
            }
        }

        def projectLibsSpec = copySpec {
            def libProjects = project(':aaa').subprojects +
                              project(':bb').subprojects +
                              project(':ccc').subprojects.findAll { !it.name != 'w' } +
                              project(':ddd').subprojects +
                              project(':eee').subprojects.findAll { it.name.startsWith('m') } +
                              [project(':fff:ggg'),
                               project(':hhh:h')]
            from(libProjects*.configurations.runtime.allArtifacts.files) {
                into libDirName
            }
        }


        def fileSystemSpec = copySpec {
            def fileSystemProjects = [project(':ii'),
                                      project(':jj')]
            fileSystemProjects.each { fileSystemProject ->
                from(fileSystemProject.file('src/main/filesystem/bin')) {
                    into 'bin'
                    dirMode = 0755
                    fileMode = 0755
                }

                from(fileSystemProject.file('src/main/filesystem')) {
                    exclude 'bin/**'
                    exclude 'conf/**/*.zip'
                }
            }
        }

        aTar {
            with externalLibsSpec
            with projectLibsSpec
            with fileSystemSpec
        }
    }
}

task aTar(type: Tar, dependsOn: configureTar) {
    compression = Compression.GZIP
    archiveName = "${project.name}-${project.version}.tar.gz"

    into "${project.name}-${project.version}"
   }

(Sterling Greene) #2

Hey Ankit,

Could you run again with -S and provide the longer stacktrace? I’m looking for the line that the NPE is coming from.

Thanks!


(Sterling Greene) #3

Also, could you try changing:

                rename { String fileName ->
                    if (fileName.contains('aspectjweaver')) {
                        fileName.replaceAll('(.+)-(.+).jar', '$1.jar')
                    }
                    else if  (fileName.contains('jolokia')) {
                        fileName.replaceAll('(.+)-(.+)-(.+)\\.jar', '$1.jar')
                    }
                }

to

                rename { String fileName ->
                    if (fileName.contains('aspectjweaver')) {
                        fileName.replaceAll('(.+)-(.+).jar', '$1.jar')
                    }
                    else if  (fileName.contains('jolokia')) {
                        fileName.replaceAll('(.+)-(.+)-(.+)\\.jar', '$1.jar')
                    } else {
                        fileName
                    }
                }

This is just a workaround. I raised GRADLE-3569 (which I think is your issue, but the stacktrace would confirm it).


(Ankit ) #4

Here is the full stacktrace:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':assistant:assistant:assistantTar'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:233)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:74)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:55)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.api.GradleException: Could not add file '/Users/ankitsrivastava/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar' to TAR '/Users/ankitsrivastava/projects/a/b/c/d/tar-ball/build/distributions/e-23.tar.gz'.
        at org.gradle.api.internal.file.archive.TarCopyAction$StreamAction.visitFile(TarCopyAction.java:97)
        at org.gradle.api.internal.file.archive.TarCopyAction$StreamAction.processFile(TarCopyAction.java:83)
        at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1$1.processFile(NormalizingCopyActionDecorator.java:66)
        at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1$1.processFile(DuplicateHandlingCopyActionDecorator.java:60)
        at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.processFile(CopyFileVisitorImpl.java:60)
        at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.visitFile(CopyFileVisitorImpl.java:44)
        at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl$1.visitFile(AbstractFileTree.java:150)
        at org.gradle.api.internal.file.collections.SingletonFileTree.visit(SingletonFileTree.java:44)
        at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:109)
        at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl.visit(AbstractFileTree.java:141)
        at org.gradle.api.internal.file.CompositeFileTree.visit(CompositeFileTree.java:58)
        at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:37)
        at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:24)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:570)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:572)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:572)
        at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:572)
        at org.gradle.api.internal.file.copy.DefaultCopySpec.walk(DefaultCopySpec.java:380)
        at org.gradle.api.internal.file.copy.CopySpecBackedCopyActionProcessingStream.process(CopySpecBackedCopyActionProcessingStream.java:36)
        at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1.process(DuplicateHandlingCopyActionDecorator.java:44)
        at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1.process(NormalizingCopyActionDecorator.java:57)
        at org.gradle.api.internal.file.archive.TarCopyAction$1.doExecute(TarCopyAction.java:64)
        at org.gradle.api.internal.file.archive.TarCopyAction$1.doExecute(TarCopyAction.java:54)
        at org.gradle.internal.ErroringAction.execute(ErroringAction.java:35)
        at org.gradle.internal.IoActions.withResource(IoActions.java:74)
        at org.gradle.api.internal.file.archive.TarCopyAction.execute(TarCopyAction.java:54)
        at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:53)
        at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator.execute(DuplicateHandlingCopyActionDecorator.java:42)
        at org.gradle.api.internal.file.copy.CopyActionExecuter.execute(CopyActionExecuter.java:38)
        at org.gradle.api.tasks.AbstractCopyTask.copy(AbstractCopyTask.java:94)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:136)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:129)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:118)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:623)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:606)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 17 more
Caused by: java.lang.NullPointerException
        at org.gradle.util.CollectionUtils.join(CollectionUtils.java:550)
        at org.gradle.util.CollectionUtils.join(CollectionUtils.java:517)
        at org.gradle.api.file.RelativePath.getPathString(RelativePath.java:100)
        at org.gradle.api.internal.file.archive.TarCopyAction$StreamAction.visitFile(TarCopyAction.java:89)
        ... 58 more


BUILD FAILED

I was able to create the tarball after trying your workaround.

Thanks!


(Piotr Jagielski) #5

FYI, GRADLE-3569 is resolved in 3.2.