getodk / aggregate

ODK Aggregate is a Java server that stores, analyzes, and presents survey data collected using ODK Collect. Contribute and make the world a better place! ✨🗄✨
https://docs.opendatakit.org/aggregate-intro/
Other
74 stars 227 forks source link

Had to fix Util.groovy setPropertiesValue for "./gradlew clean dockerComposeBuild -xtest -PwarMode=complete" #480

Closed arkanoid87 closed 4 years ago

arkanoid87 commented 4 years ago

Software and hardware versions

Windows/Linux/macOS, Aggregate v1.x.x, Java vx.x.x, ... Ubuntu 18.04.2 LTS java-1.11.0-openjdk-amd64

Problem description

FAILURE: Build failed with an exception.                                                                                                                                                                                                       

* Where:                                                                                                                                                                                                                                       
Script '/home/jack/docker/aggregate/docker-compose.gradle' line: 18                                                                                                                                                                            

* What went wrong:                                                                                                                                                                                                                             
Execution failed for task ':dockerComposeBuild'.                                                                                                                                                                                               
> java.io.FileNotFoundException: /home/jack/docker/aggregate/build/docker-compose/webapps/ROOT/WEB-INF/classes/jdbc.properties (No such file or directory)

Steps to reproduce the problem

gradle clean dockerComposeBuild -xtest -PwarMode=complete

Expected behavior

"Your Docker Compose build for Aggregate is in build/docker-compose."

Other information

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':dockerComposeBuild'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.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:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.UncheckedIOException: java.io.FileNotFoundException: /home/jack/docker/aggregate/build/docker-compose/webapps/ROOT/WEB-INF/classes/jdbc.properties (No such file or directory)
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:57)
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:151)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        ... 29 more
Caused by: java.io.FileNotFoundException: /home/jack/docker/aggregate/build/docker-compose/webapps/ROOT/WEB-INF/classes/jdbc.properties (No such file or directory)
        at org.opendatakit.aggregate.gradle.Util.setPropertiesValue(Util.groovy:30)
        at org.opendatakit.aggregate.gradle.Util$setPropertiesValue.callStatic(Unknown Source)
        at docker_compose_2i51aeensx5mkepnzy27p261y$_run_closure2$_closure4.doCall(/home/jack/docker/aggregate/docker-compose.gradle:18)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:718)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:691)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
        ... 35 more

By reading docker-compose.gradle and not getting this error anywhere else during the execution, it seemed to me that the intended behaviour was to create the .properties file if that doesn't exists, so I tried hotpatching the script by adding line "propsFile.createNewFile()" in buildSrc/src/main/groovy/org/opendatakit/aggregate/gradle/Util.groovy and I got "BUILD SUCCEEDED". Please does not consider this a proper solution.

   static def setPropertiesValue(path, String key, value) {                                                                                                                                                                                    
     Properties props = new Properties()                                                                                                                                                                                                       
     File propsFile = new File(path.toString())                                                                                                                                                                                                
     propsFile.createNewFile()                                                                                                                                                                                                                 
     props.load(propsFile.newDataInputStream())                                                                                                                                                                                                

     props.setProperty(key, value.toString())                                                                                                                                                                                                  
     props.store(propsFile.newWriter(), null)                                                                                                                                                                                                  
     println("Set ${path}:${key} to \"${value}\"")                                                                                                                                                                                             
   } 
arkanoid87 commented 4 years ago

Just figured out that the error was on my side but it was due to a lack of info in https://github.com/opendatakit/aggregate/blob/master/docs/build-and-run-with-docker-compose.md doesn't say anything about copying configuration files

Just copy the jdbc.properties.example, odk-settings.xml.example, and security.properties.example files at /src/main/resources to the same location, removing the .example extension like stated in main README.md

It is possible to bind mount them later like suggested in https://github.com/opendatakit/aggregate/blob/master/docs/build-and-run-a-docker-image.md

lognaturel commented 4 years ago

Sorry you ran into an issue, @arkanoid87, and it's great to see you were able to resolve it. Would you like to submit a quick update to the docs file to help future users out? You should be able to do this entirely in the Github interface by clicking the pencil/edit icon if you don't want to fork the repository. Thanks!