Can I set a directory as an artifact?


(spamflowers) #1

The following example script works when I specify the file ‘build/resources/main/test.txt’, but fails if I use ‘build/resources/main’ (warning, very newbie code ahead):

configurations {
 archives
}
  artifacts {
 archives( file('build/resources/main/') ) {
  name 'myres'
  type 'dir'
  builtBy 'build'
 }
}

Here’s the error I get when specifying a directory:

  • What went wrong: A problem occurred evaluating project ‘:jettbase’. > Failed to notify action.

    java.lang.NullPointerException (no error message)

  • Try: Run with --debug option to get more log output.

  • Exception is: org.gradle.api.GradleScriptException: A problem occurred evaluating project ‘:jettbase’.

at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)

at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)

at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)

at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:44)

at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:464)

at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:77)

at org.gradle.configuration.DefaultBuildConfigurer$ConfigureProject.execute(DefaultBuildConfigurer.java:38)

at org.gradle.configuration.DefaultBuildConfigurer$ConfigureProject.execute(DefaultBuildConfigurer.java:36)

at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:440)

at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:435)

at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:32)

at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)

at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)

at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)

at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38)

at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)

at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)

at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:70)

at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:68)

at org.gradle.util.Swapper.swap(Swapper.java:38)

at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:68)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)

at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:59)

at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)

at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)

at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)

at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)

at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)

at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:48)

at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)

at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)

at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)

at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66) Caused by: org.gradle.listener.ListenerNotificationException: Failed to notify action.

at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:90)

at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)

at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)

at com.sun.proxy.$Proxy3.execute(Unknown Source)

at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:30)

at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:164)

at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:159)

at org.gradle.api.internal.DelegatingDomainObjectSet.add(DelegatingDomainObjectSet.java:80)

at java_util_Set$add.call(Unknown Source)

at org.gradle.api.internal.artifacts.dsl.DefaultArtifactHandler.pushArtifact(DefaultArtifactHandler.groovy:42)

at org.gradle.api.internal.artifacts.dsl.DefaultArtifactHandler.this$2$pushArtifact(DefaultArtifactHandler.groovy)

at org.gradle.api.internal.artifacts.dsl.DefaultArtifactHandler.methodMissing(DefaultArtifactHandler.groovy:64)

at org.gradle.api.internal.artifacts.dsl.DefaultArtifactHandler.invokeMethod(DefaultArtifactHandler.groovy)

at build_c6veh7ou0ie9nkcjmnqs2ddj1$_run_closure2.doCall(/Users/jflowers/Projects/jett/core/jettbase/build.gradle:6)

at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:133)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:94)

at org.gradle.api.internal.project.AbstractProject.artifacts(AbstractProject.java:889)

at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)

at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)

at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)

at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83)

at build_c6veh7ou0ie9nkcjmnqs2ddj1.run(/Users/jflowers/Projects/jett/core/jettbase/build.gradle:5)

at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)

… 51 more Caused by: java.lang.NullPointerException

at org.gradle.api.internal.plugins.DefaultArtifactPublicationSet.addCandidate(DefaultArtifactPublicationSet.java:41)

at org.gradle.api.plugins.BasePlugin$3$1.execute(BasePlugin.java:146)

at org.gradle.api.plugins.BasePlugin$3$1.execute(BasePlugin.java:144)

at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)

at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)

at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:81)

… 74 more

Here’s the output of gradle -v:

------------------------------------------------------------ Gradle 1.5 ------------------------------------------------------------

Gradle build time: Wednesday, March 27, 2013 1:51:06 PM UTC Groovy: 1.8.6 Ant: Apache Ant™ version 1.8.4 compiled on May 22 2012 Ivy: 2.2.0 JVM: 1.6.0_45 (Apple Inc. 20.45-b01-451) OS: Mac OS X 10.8.3 x86_64

Thanks for any help,

josh


(Peter Niederwieser) #2

An artifact is always a file. Besides passing the file directly, you can also pass an archive task (e.g. ‘jar’), which then stands for the file produced by the task.

PS: The exception seems to be caused by an artifact that does not have a ‘type’ set.


(spamflowers) #3

Thanks for the quick response Peter.

Given that a directory can’t be an artifact, what’s the most idiomatic way to mimic using a directory as an artifact?

i.e. in my example I would like treat the entire build/resources/main/ directory as the product of my build. Is there a ‘normal’ way to do this?

Thanks again,

josh


(Peter Niederwieser) #4

Depending on the expectations/needs of consumers of the artifact, you might want to create a Zip or Tar archive.