问题描述
我是Gradle的新手,目前我添加了一个小型的Java项目并且执行得很好。
如果我对Java的理解能够解决, java项目并且执行得很好。
为了测试我使用junit的帮助测试了一个测试类,但是我无法编译并且无法将依赖从maven有一个问题。
当我用stacktrace选项检查时,我发现问题是 java.net.UnknownHostException:repo1.maven.org strong>当我试图通过谷歌访问它说目录浏览被禁用,也许它可能只是为了拉动依赖。
下面我已经给出了随着错误的细节。
请帮助我解决问题,或者如果我的理解错误,请建议如何继续或纠正我。
Java类的编译
没有堆栈跟踪的Junit编译
汇编Junit with Stack Trace
D:\Public\NetbeansApp\ShopCart> gradle -s build
:compileJava
:processResources UP-TO-DATE
:classes
:jar UP-TO-DATE
:汇编UP-TO-DATE
:compileTestJava
失败:构建失败,出现异常。
*出错:
无法解析配置':testCompile'的所有依赖关系。
>无法解决junit:junit:4.12。
要求:
:ShopCart:未指定
>无法GET'https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.pom'。
> repo1.maven.org
*尝试:
使用--info或--debug选项运行以获取更多日志输出。
*例外情况是:
org.gradle.api.artifacts.ResolveException:无法解析配置':testCompile'的所有依赖关系。
在org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.rethrowFailure(DefaultLenientConfiguration.java:52)
在org.gradle.api.internal.artifacts.ivyservice.DefaultResolvedConfiguration.rethrowFailure(DefaultResolvedConfiguration。
at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver $ FilesAggregatingResolvedConfiguration.rethrowFailure(SelfResol
vingDependencyResolver.java:110)
at org.gradle.api.internal .org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
$ ConfigurationFileCollection.getFiles(DefaultConfiguration.java:444) )
在org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:205)
at org.gradle.api.inte rnal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(来源不明)
在org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext $ FileTreeConverter.convertInto(DefaultFileCollectionResolveCont
ext.java:191)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:103)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileTrees(DefaultFileCollectionResolveContext.java:75
)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext $ FileTreeConverter.convertInto(DefaultFileCollectionResolveCont
ext.java:182)
at org.gradle.api。 internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:98)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFi leTrees(DefaultFileCollectionResolveContext.java:75
)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext $ FileTreeConverter.convertInto(DefaultFileCollectionResolveCont
ext.java:182)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:98)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileTrees(DefaultFileCollectionResolveContext.java:75
)
at org.gradle.api.internal.file.CompositeFileCollection $ 1.resolve(CompositeFileCollection.java:88)
at org.gradle.api.internal.file.CompositeFileCollection.getSourceCollections(CompositeFileCollection .java:143)
at org.gradle.api.internal.file.CompositeFileTree.getSourceCollections(CompositeFileTree.java:30)
at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection的.java:3 8)
at org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter.snapshot(DefaultFileCollectionSnapshotter.java:47)
at org.gradle.api.internal.changedetection.rules.TaskUpToDateState。< (org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository $ TaskArtifactStateImpl.getStates(DefaultTaskArtifactState
Repository.java:126)
at org。 $ org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter)
eRepository.java:69 $。 java:52)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter。执行(SkipEmptySourceFilesTaskExec在org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
org.gradle.api.internal.tasks.execution
。 SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
在org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
。在org.gradle.api.internal。 AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
在org.gradle.execution.taskgraph.AbstractTaskPlanExecutor $ TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
。在org.gradle.execution.taskgraph.AbstractTaskPlanExecutor $ TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)维持在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor org.gradle.execution.taskgraph.AbstractTaskPlanExecutor $ TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
。过程(DefaultTa skPlanExecutor.java:23)
在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
在org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access $ 200(DefaultBuildExecuter.java:23)
at org。 gradle.execution.DefaultBuildExecuter $ 2.proceed(DefaultBuildExecuter.java:68)在org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
在org.gradle.execution.DefaultBuildExecuter.execute (DefaultBuildExecuter.java:62)在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
在org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
在org.gradle.initialization.Default GradleLauncher.doBuild(DefaultGradleLauncher.java:106)
在org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
在org.gradle.launcher.exec.InProcessBuildActionExecuter $ DefaultBuildController.run( InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java: 24)
。在org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
。在org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions $ RunnableActionAdapter.execute(Actions.java:171)
at org .gradle.launcher.cli.CommandLineActionFactory $ ParseAndBuildAction.execute(CommandLineActionFactory.java :237)
在org.gradle.launcher.cli.CommandLineActionFactory $ ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
在org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35 )美元,org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24 b $ b)
在org.gradle.launcher.cli.CommandLineActionFactory $ WithLogging.execute(CommandLineActionFactory.java:206)
。在org.gradle.launcher.cli.CommandLineActionFactory $ WithLogging.execute(CommandLineActionFactory.java:169)
在org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
在org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
在org.gradle.launcher.Main.doAction(Main.java:33)
在org.gradle。 launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.boots trap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main( GradleMain.java:23)
导致:org.gradle.internal.resolve.ModuleVersionResolveException:无法解析junit:junit:4.12。
要求:
:ShopCart:未指定
在org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.resolve(RepositoryChainDependencyResolver.java:81
)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainAdapter.resolve(RepositoryChainAdapter.java:69)
at org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver.resolve( ClientModuleResolver.java:44)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder $ ModuleVersionResolveState.resolve(DependencyGraphBu
ilder.java:577)
at org .gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder $ ModuleVersionResolveState.getMetaData(DependencyGra
phBuilder.java:587)
在org.gradle.api.internal.artifacts.ivyservice.resolveengine .graph.DependencyGraphBuilder $ DependencyEdge.calculateTargetConfigurations(取决于
e ncyGraphBuilder.java:272)
在org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder $ DependencyEdge.attachToTargetConfigurations(Depende
ncyGraphBuilder.java:246)
。在组织.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:156)
在org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.resolveDependencyGraph( DependencyGraphBuilder.java:
94)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:84)
at org.gradle。 api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver $ 1.execute(DefaultDependencyResolver.java:122)
在org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver $ 1.execute(DefaultDependencyResolver.java:88 )在org.gradle.interna
l.Transformers $ 4.transform(Transformers.java:136)
at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61)
at org.gradle.api .internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver.resolve(DefaultDependencyResolver.java:88)
at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver $ 1.run(CacheLockingArtifactDependencyResolver.java:42)
at org.gradle.internal.Factories $ 1.create(Factories.java:22)
org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:187)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
at org.gradle .cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
在org.gradle.cache.internal.DefaultCacheFactory $ ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
在org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java: 64)
位于org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:40)
位于org.gradle.api.internal.artifacts.ivyservice。 SelfResolvingDependencyResolver.resolve(SelfResolvingDependencyResolver.java:45)
at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsArtifactDependencyResolver.resolve(ShortcircuitEmptyConfigsArtifactDep
endencyResolver.java:55)
at org.gradle .api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.resolve(ErrorHandlingArtifactDependencyResolver.java:4
7)
at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolve r.resolve(DefaultConfigurationResolver.java:46)
位于org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveNow(DefaultConfiguration.java:250)
位于org.gradle.api.internal。 artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:240)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
at org.gradle.api.internal .artifacts.configurations.DefaultConfiguration $ ConfigurationFileCollection.getFiles(DefaultConfiguration.java:442)
... 61 more
导致:org.gradle.internal.resource.transport.http.HttpRequestException:无法获取'https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12
.pom'。
at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:80)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performRawGet(HttpClientHelper。 java:66)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performGet(HttpClientHelper.java:70)
at org.gradle.internal.resource.transport.http.HttpResourceAccessor。 getResource(HttpResourceAccessor.java:53)
位于org.gradle.internal.resource.transport.http.HttpResourceAccessor.getResource(HttpResourceAccessor.java:36)
位于org.gradle.internal.resource.transfer。在org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.getResource ProgressLoggingExternalResourceAccessor.getResource(ProgressLoggingExternalResourceAccessor.java:39)
(DefaultCacheAwareExternalResourceAccessor.java:
72)在org.gradle.api
。 internal.artifacts.repositories.resolver.DefaultExtern alResourceArtifactResolver.downloadStaticResource(DefaultExternalResou
rceArtifactResolver.java:91)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.resolveMetaDataArtifact(DefaultExternalReso
urceArtifactResolver.java:57)
位于org.gradle.api.internal.artifacts.repositories的org.gradle.api.internal.artifacts.repositories.resolver.ExternalResolver.parseMetaDataFromArtifact(ExternalResourceResolver.java:16
2)
。 resolver.ExternalResourceResolver.resolveStaticDependency(ExternalResourceResolver.java:141)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.doResolveComponentMetaData(MavenResolver.java:82)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver $ RemoteRepositoryAccess.resolveComponentMetaData(ExternalRe
sourceResolver.java:391)
at org.gradle.api.internal.artifacts.ivyser vice.ivyresolve.CacheLockReleasingModuleComponentsRepository $ $ LockReleasingRepositoryAccess 2.run(CA
cheLockReleasingModuleComponentsRepository.java:65)
。在org.gradle.internal.Factories $ 1。创建(Factories.java:22)$ B $在有机b .gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:237)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:308)
at org.gradle.cache .internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:114)
在org.gradle.cache.internal.DefaultCacheFactory $ ReferenceTrackingCache.longRunningOperation(DefaultCacheFactory.java:179)
在org.gradle.api.internal .artifacts.ivyservice.DefaultCacheLockingManager.longRunningOperation(DefaultCacheLockingManager.java:56)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockReleasingModuleComponentsRepository $ LockReleasin gRepositoryAccess.resolveC
omponentMetaData(CacheLockReleasingModuleComponentsRepository.java:63)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository $ ResolveAndCacheRepositoryAccess.resolveComponentMe
taData(CachingModuleComponentRepository.java:284 )在org.gradle.api.internal.artifacts.ivyservice.ivyresolve.BaseModuleComponentRepositoryAccess.resolveComponentMetaData
(BaseModuleComponentRep
ositoryAccess.java:38)在org.gradle.api.internal.artifacts
。 ivyservice.ivyresolve.memcache.InMemoryCachedModuleComponentRepository $ CachedAccess.resolveComponentMetaD
ata(InMemoryCachedModuleComponentRepository.java:70)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.process(ComponentMetaDataResolveState.java: 70)
在org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.resolve(ComponentMetaDataResolveState .java:62)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.findBestMatch(RepositoryChainDependencyResolver.j
ava:114)
at org.gradle.api。在org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.resolve中存储
(RepositoryChainDependencyResolver.java: 70
)
... 92 more
由java.net.UnknownHostException引发:repo1.maven.org
在org.apache.http.impl.conn.SystemDefaultDnsResolver。 (org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278)
在org.apache.http.impl.conn.DefaultClientConnectionOperator中解析(SystemDefaultDnsResolver.java:45)
。 openConnection(DefaultClientConnectionOperator.java:162)
在org.apache.h ttp.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
位于org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
位于org.apache。 http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
在org.apache。 http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:137)
处org.gradle org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:118)
。 internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:111)
在org.gradle.internal.resource.transport.http.HttpClientHelper.executeGetOrHead(HttpClientHelper.java:87)
。在org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:78)
.. 。120 more
建立失败
总时间:14.846秒
D:\ Public \NetbeansApp\ShopCart>
使用测试类的应用程序项目结构
构建脚本
apply plugin:'java'
sourceCompatibility ='1.7'
[compileJava,compileTestJava] *。options * .encoding ='UTF-8'
// NetBeans将自动添加依赖于run和debug任务的任务
//mainClass属性。然而,您可以在执行
//任务之前定义属性,方法是传递-PmainClass =< QUALIFIED_CLASS_NAME>论据。
//
//然而请注意,如果您
//偏好,您可以定义自己的运行和调试任务。在这种情况下,NetBeans不会添加这些任务,但您可能依赖于
//您自己的实现。
if(!hasProperty('mainClass')){
ext.mainClass =''
}
jar {
manifest {
属性'Main-Class':'com.gradle.shopcart.ShopCartApp'
}
}
仓库{
mavenCentral()
// You可能会定义额外的存储库,甚至删除mavenCentral()。
//阅读更多关于存储库的信息:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
依赖关系{
// TODO:在这里添加依赖关系...
//你可以阅读更多关于如何在这里添加依赖关系:
// http://www.gradle .org / docs / current / userguide / dependency_management.html#sec:how_to_declare_your_dependencies
testCompile group:'junit',name:'junit',version:'4.12'
}
号码簿错误
通过代理访问网络
。
通常这不起作用,因为公司代理是一个特殊 em>需要特殊认证机制(NTLM)的代理。因此,您应该查看。 Cntlm是一个本地HTTP代理服务器,它能够对您的公司代理进行身份验证,并将流量从本地代理转发到公司代理服务器。
另外一个解决方案是自己的Maven仓库像或。I'm new to Gradle, currently i added a small java projects and executed well.
Correct me if my understanding since java is available we are able to complie the java project and executed well.
To test i have wirtten a test class with help of junit, but I couldn't not compile and not able to pull the dependency from the maven there was an issue.
When I checked with stacktrace option I find that the issue is java.net.UnknownHostException: repo1.maven.org when i tried to access through google it says the Directory browsing is disabled, perhaps it may only for pulling dependency.
Below I have given the steps followed along with the error details.
Kindly help me how to resolve or please suggest how to proceed or correct me if my understanding is wrong.
Compilation of Java Class
Compilation of Junit without stacktrace
Compilation of Junit with Stack Trace
D:\Public\NetbeansApp\ShopCart>gradle -s build
:compileJava
:processResources UP-TO-DATE
:classes
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':testCompile'.
> Could not resolve junit:junit:4.12.
Required by:
:ShopCart:unspecified
> Could not GET 'https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.pom'.
> repo1.maven.org
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':testCompile'.
at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.rethrowFailure(DefaultLenientConfiguration.java:52)
at org.gradle.api.internal.artifacts.ivyservice.DefaultResolvedConfiguration.rethrowFailure(DefaultResolvedConfiguration.java:36)
at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver$FilesAggregatingResolvedConfiguration.rethrowFailure(SelfResol
vingDependencyResolver.java:110)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$ErrorHandlingResolvedConfiguration.rethrowFailure(Erro
rHandlingArtifactDependencyResolver.java:180)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:444)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:205)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileTreeConverter.convertInto(DefaultFileCollectionResolveCont
ext.java:191)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:103)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileTrees(DefaultFileCollectionResolveContext.java:75
)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileTreeConverter.convertInto(DefaultFileCollectionResolveCont
ext.java:182)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:98)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileTrees(DefaultFileCollectionResolveContext.java:75
)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileTreeConverter.convertInto(DefaultFileCollectionResolveCont
ext.java:182)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:98)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileTrees(DefaultFileCollectionResolveContext.java:75
)
at org.gradle.api.internal.file.CompositeFileCollection$1.resolve(CompositeFileCollection.java:88)
at org.gradle.api.internal.file.CompositeFileCollection.getSourceCollections(CompositeFileCollection.java:143)
at org.gradle.api.internal.file.CompositeFileTree.getSourceCollections(CompositeFileTree.java:30)
at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection.java:38)
at org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter.snapshot(DefaultFileCollectionSnapshotter.java:47)
at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.<init>(TaskUpToDateState.java:55)
at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.getStates(DefaultTaskArtifactState
Repository.java:126)
at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStat
eRepository.java:69)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
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.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve junit:junit:4.12.
Required by:
:ShopCart:unspecified
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.resolve(RepositoryChainDependencyResolver.java:81
)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainAdapter.resolve(RepositoryChainAdapter.java:69)
at org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver.resolve(ClientModuleResolver.java:44)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$ModuleVersionResolveState.resolve(DependencyGraphBu
ilder.java:577)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$ModuleVersionResolveState.getMetaData(DependencyGra
phBuilder.java:587)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$DependencyEdge.calculateTargetConfigurations(Depend
encyGraphBuilder.java:272)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$DependencyEdge.attachToTargetConfigurations(Depende
ncyGraphBuilder.java:246)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:156)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.resolveDependencyGraph(DependencyGraphBuilder.java:
94)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:84)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver$1.execute(DefaultDependencyResolver.java:122)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver$1.execute(DefaultDependencyResolver.java:88)
at org.gradle.internal.Transformers$4.transform(Transformers.java:136)
at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61)
at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver.resolve(DefaultDependencyResolver.java:88)
at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.run(CacheLockingArtifactDependencyResolver.java:42)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:187)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:64)
at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:40)
at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver.resolve(SelfResolvingDependencyResolver.java:45)
at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsArtifactDependencyResolver.resolve(ShortcircuitEmptyConfigsArtifactDep
endencyResolver.java:55)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.resolve(ErrorHandlingArtifactDependencyResolver.java:4
7)
at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolve(DefaultConfigurationResolver.java:46)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveNow(DefaultConfiguration.java:250)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:240)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:442)
... 61 more
Caused by: org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12
.pom'.
at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:80)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performRawGet(HttpClientHelper.java:66)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performGet(HttpClientHelper.java:70)
at org.gradle.internal.resource.transport.http.HttpResourceAccessor.getResource(HttpResourceAccessor.java:53)
at org.gradle.internal.resource.transport.http.HttpResourceAccessor.getResource(HttpResourceAccessor.java:36)
at org.gradle.internal.resource.transfer.ProgressLoggingExternalResourceAccessor.getResource(ProgressLoggingExternalResourceAccessor.java:39)
at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.getResource(DefaultCacheAwareExternalResourceAccessor.java:
72)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadStaticResource(DefaultExternalResou
rceArtifactResolver.java:91)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.resolveMetaDataArtifact(DefaultExternalReso
urceArtifactResolver.java:57)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.parseMetaDataFromArtifact(ExternalResourceResolver.java:16
2)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.resolveStaticDependency(ExternalResourceResolver.java:141)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.doResolveComponentMetaData(MavenResolver.java:82)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveComponentMetaData(ExternalRe
sourceResolver.java:391)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockReleasingModuleComponentsRepository$LockReleasingRepositoryAccess$2.run(Ca
cheLockReleasingModuleComponentsRepository.java:65)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:237)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:308)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:114)
at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.longRunningOperation(DefaultCacheFactory.java:179)
at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.longRunningOperation(DefaultCacheLockingManager.java:56)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockReleasingModuleComponentsRepository$LockReleasingRepositoryAccess.resolveC
omponentMetaData(CacheLockReleasingModuleComponentsRepository.java:63)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$ResolveAndCacheRepositoryAccess.resolveComponentMe
taData(CachingModuleComponentRepository.java:284)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.BaseModuleComponentRepositoryAccess.resolveComponentMetaData(BaseModuleComponentRep
ositoryAccess.java:38)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedModuleComponentRepository$CachedAccess.resolveComponentMetaD
ata(InMemoryCachedModuleComponentRepository.java:70)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.process(ComponentMetaDataResolveState.java:70)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.resolve(ComponentMetaDataResolveState.java:62)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.findBestMatch(RepositoryChainDependencyResolver.j
ava:114)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.findBestMatch(RepositoryChainDependencyResolver.j
ava:97)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.resolve(RepositoryChainDependencyResolver.java:70
)
... 92 more
Caused by: java.net.UnknownHostException: repo1.maven.org
at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:137)
at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:118)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:111)
at org.gradle.internal.resource.transport.http.HttpClientHelper.executeGetOrHead(HttpClientHelper.java:87)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:78)
... 120 more
BUILD FAILED
Total time: 14.846 secs
D:\Public\NetbeansApp\ShopCart>
App project structure with Test Class
Build script
apply plugin: 'java'
sourceCompatibility = '1.7'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
jar {
manifest {
attributes 'Main-Class': 'com.gradle.shopcart.ShopCartApp'
}
}
repositories {
mavenCentral()
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
// TODO: Add dependencies here ...
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
testCompile group: 'junit', name: 'junit', version: '4.12'
}
Error of Directory
As you commented you are trying to make it work behind a corporate proxy. You need to setup your Gradle properly, so it can load the dependencies with the proxy in mind. To do so you should follow the Gradle User Guide section 20.2. Accessing the web via a proxy
.
Often this doesn't work either because the corporate proxy is a special proxy which required a special authentication mechanism (NTLM). Therefore you should check out the Cntlm Authentication Proxy. Cntlm is a local HTTP Proxy which is able to authentication against your corporate proxy and forward the traffic from the local proxy to corporate proxy.
Another solutions would be a own Maven Repository Server/Proxy/Cache like Artifactory or Nexus.
这篇关于如何解决依赖关系并使用Gradle Bulid Tool编译Junit测试类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!