title: Maven - Cannot create resource output directory in a shell script
body: <p>I am trying to execute a maven build in a shell script. I am running on Amazon Linux in an ec2 instance. </p>
  
  <p>Here are the first two lines of my script which I'm having trouble with:</p>
  
  <pre><code>sudo git clone [url of git repository]
  
  sudo mvn clean package -f /path/to/pom.xml
  </code></pre>
  
  <p>If I enter each of them individually in the command line then it works. </p>
  
  <p>If I have the repository already cloned and then execute the script, it works. It skips cloning the repository (because it's already present) and continues with the rest of the script. Once again, this works.</p>
  
  <p>The problem occurs when the repo isn't present and I run the script. It clones the remote repo and appears to be successful. </p>
  
  <p>But when it tries to package the project I run into this error:</p>
  
  <p>You can see that the repo is cloned and then the build initiates, but fails. I have even tried waiting 5 seconds between the clone and the mvn package command. </p>
  
  <pre><code>[ec2-user@ip-10-0-1-16 ~]$ build_script
  Cloning into 'devops'...
  remote: Counting objects: 649, done.
  remote: Compressing objects: 100% (548/548), done.
  remote: Total 649 (delta 314), reused 88 (delta 24)
  Receiving objects: 100% (649/649), 18.96 MiB | 0 bytes/s, done.
  Resolving deltas: 100% (314/314), done.
  Checking connectivity... done.
  [INFO] Scanning for projects...
  [INFO]
  [INFO] ------------------------------------------------------------------------
  [INFO] Building UserRegistrationClient current
  [INFO] ------------------------------------------------------------------------
  [INFO]
  [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ demo ---
  [INFO]
  [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo ---
  [INFO] Using 'UTF-8' encoding to copy filtered resources.
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 1.890 s
  [INFO] Finished at: 2015-08-28T18:43:04+00:00
  [INFO] Final Memory: 11M/26M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project demo: Cannot create resource output directory: /home/ec2-user/devops/UserRegistrationClient/target/classes -&gt; [Help 1]
  [ERROR]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR]
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  </code></pre>