构建spring框架源代码遇到错误

时间:2016-01-21 06:40:58

标签: java spring git gradle

我使用git clone命令从github获取了spring框架源代码。当我在源代码目录中使用gradle build构建源代码时,下载依赖项并编译java代码需要很长时间,但是因异常而失败。输出如下。

:spring-webmvc-portlet:sourcesJar UP-TO-DATE
:spring-webmvc-tiles2:javadoc SKIPPED
:spring-webmvc-tiles2:javadocJar SKIPPED
:spring-webmvc-tiles2:sourcesJar SKIPPED
:spring-websocket:javadoc UP-TO-DATE
:spring-websocket:javadocJar UP-TO-DATE
:spring-websocket:sourcesJar UP-TO-DATE
:distZip

FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture snapshot of input files for task 'distZip' during up-to-date c
heck.  See stacktrace for details.
> java.io.FileNotFoundException: C:\Users\yuqing\workspace\spring-framework\buil
d\distributions\spring-framework-4.3.0.BUILD-SNAPSHOT-schema.zip 

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.UncheckedIOException: Failed to capture snapshot of input files f
or task 'distZip' during up-to-date check.  See stacktrace for details.
        at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.<init
>(TaskUpToDateState.java:60)
        at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactSt
ateRepository$TaskArtifactStateImpl.getStates(DefaultTaskArtifactStateRepository
.java:132)
        at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactSt
ateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepositor
y.java:70)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.exec
ute(SkipUpToDateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execut
e(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecu
ter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter
.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execut
e(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter
.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
skWorker.execute(DefaultTaskGraphExecuter.java:203)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
skWorker.execute(DefaultTaskGraphExecuter.java:185)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.processTask(AbstractTaskPlanExecutor.java:66)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.run(AbstractTaskPlanExecutor.java:50)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(Defaul
tTaskPlanExecutor.java:25)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(Defau
ltTaskGraphExecuter.java:110)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTask
ExecutionAction.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:37)
        at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExec
uter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecu
ter.java:43)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildEx
ecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:30)
        at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLa
uncher.java:154)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:52)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:151)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGra
dleLauncher.java:32)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:99)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:93)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:62)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:93)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:82)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
....
Caused by: org.gradle.api.UncheckedIOException: java.io.FileNotFoundException: C
:\Users\yuqing\workspace\spring-framework\build\distributions\spring-framework-4
.3.0.BUILD-SNAPSHOT-schema.zip (系统找不到指定的文件。)
        at org.gradle.internal.hash.HashUtil.createHash(HashUtil.java:39)
        at org.gradle.api.internal.hash.DefaultHasher.hash(DefaultHasher.java:24
)
        at org.gradle.api.internal.changedetection.state.CachingFileSnapshotter.
snapshot(CachingFileSnapshotter.java:57)
        at org.gradle.api.internal.changedetection.state.CachingFileSnapshotter.
snapshot(CachingFileSnapshotter.java:46)
        at org.gradle.api.internal.changedetection.state.CachingFileSnapshotter.
snapshot(CachingFileSnapshotter.java:29)
        at org.gradle.api.internal.changedetection.state.DefaultFileCollectionSn
apshotter$1.run(DefaultFileCollectionSnapshotter.java:70)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAcc
ess.java:192)
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAcc
ess.java:175)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(De
faultPersistentDirectoryStore.java:106)
        at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.
useCache(DefaultCacheFactory.java:187)
        at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStat
eCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:60)
        at org.gradle.api.internal.changedetection.state.DefaultFileCollectionSn
apshotter.snapshot(DefaultFileCollectionSnapshotter.java:62)
        at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.<init
>(TaskUpToDateState.java:56)
        ... 57 more
Caused by: java.io.FileNotFoundException: C:\Users\yuqing\workspace\spring-frame
work\build\distributions\spring-framework-4.3.0.BUILD-SNAPSHOT-schema.zip 
        at org.gradle.internal.hash.HashUtil.createHash(HashUtil.java:34)
        ... 70 more


BUILD FAILED

Total time: 20.861 secs

错误表示找不到文件spring-framework-4.3.0.BUILD-SNAPSHOT-schema.zip。我想知道为什么找不到这个文件,它应该由distZip任务创建,但事实并非如此。 我搜索了这个问题,但没有发现任何问题。

1 个答案:

答案 0 :(得分:3)

我已经解决了这个问题,恶魔是路径分隔符。因为这个命令在windows上运行。 从

修改schemaZip任务定义
task schemaZip(type: Zip) {
        group = "Distribution"
        baseName = "spring-framework"
        classifier = "schema"
        description = "Builds -${classifier} archive containing all " +
            "XSDs for deployment at http://springframework.org/schema."
        duplicatesStrategy 'exclude'
        moduleProjects.each { subproject ->
            def Properties schemas = new Properties();

            subproject.sourceSets.main.resources.find {
                it.path.endsWith("META-INF/spring.schemas")
            }?.withInputStream { schemas.load(it) }

            for (def key : schemas.keySet()) {
                def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1')
                assert shortName != key
                File xsdFile = subproject.sourceSets.main.resources.find {
                    it.path.endsWith(schemas.get(key))
                }
                assert xsdFile != null
                into (shortName) {
                    from xsdFile.path
                }
            }
        }
    }

task schemaZip(type: Zip) {
        group = "Distribution"
        baseName = "spring-framework"
        classifier = "schema"
        description = "Builds -${classifier} archive containing all " +
            "XSDs for deployment at http://springframework.org/schema."
        duplicatesStrategy 'exclude'
        moduleProjects.each { subproject ->
            def Properties schemas = new Properties();

            subproject.sourceSets.main.resources.find {
                it.path.endsWith("META-INF\\spring.schemas")
            }?.withInputStream { schemas.load(it) }

            for (def key : schemas.keySet()) {
                def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1')
                assert shortName != key
                File xsdFile = subproject.sourceSets.main.resources.find {
                    it.path.endsWith(schemas.get(key).replaceAll('\\/','\\\\'))
                }
                assert xsdFile != null
                into (shortName) {
                    from xsdFile.path
                }
            }
        }
    }