0

We have a maven project where we use several linux bash scripts for various entries to our java application. We have solved this by the exec-maven-plugin so the scripts typically looks like: mvn -e -o -q exec:exec -Dexec.executable="java" -Dexec.args="...". For some reason, we are constrained to use tho offline flag (-o).

My question is: How do I ensure that the exec-maven-plugin is downloaded during the compile phase? There is a risk that a developer doesn't have the exec-maven-plugin downloaded and since the exec-maven-plugin is used with the maven offline flag it won't be downloaded if it is not there.

Tomas F
  • 11
  • 2
  • I'd like to control when to download something. I _think_ that the reason why we decided to use the offline flag was annoying delays due to update-checks when running our application(in combination with bad Internet connection). We can live with annoying delays during the compile phase but not when running the application. – Tomas F Sep 14 '12 at 10:24
  • could you consider specifying only intranet repository and having all your stuff there? That is a maven best practice, and you wouldn't have the lags with Internet. Assuming your intranet works fine. – eis Sep 14 '12 at 10:53
  • In fact, we have such an intranet repository, and as long as we are at the office this is not an issue. – Tomas F Sep 14 '12 at 11:55
  • so, would it be plausible if a developer (when being at office) would do `mvn dependency:go-offline`, downloading plugins and dependencies that are needed, and then use offline flag when out of office? – eis Sep 14 '12 at 13:17
  • I'm not sure how it would help me. Since the exec-maven-plugin is not specified in the pom, and only used by scripts, `dependency:go-offline` will not download exec-maven-plugin. Currently, we type `mvn exec:help` in order to download it, but I would like the system to work out-of-the-box, i.e. I would like `mvn compile` to be enough. – Tomas F Sep 14 '12 at 14:36
  • ah... Ok. I didn't realise that it wouldn't be in the pom. Would it be possible to add it and using from there, something like http://mojo.codehaus.org/exec-maven-plugin/examples/example-exec-using-plugin-dependencies.html ? – eis Sep 14 '12 at 15:05

1 Answers1

0

Thanks to the comments of @eis I managed to sort this out. The pom now looks like this:

<properties>
  <additionalJavaArgs></additionalJavaArgs>
</properties>
...
<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>1.2.1</version>
      <configuration>
        <executable>java</executable>
        <commandlineArgs>
          -XX:+PrintCommandLineFlags -showversion -classpath %classpath ${additionalJavaArgs}
        </commandlineArgs>
      </configuration>
    </plugin>
  </plugins>
</build>

The bash script looks like the following:

ADDITIONAL_JAVA_ARGS=$*
mvn -e -o -q exec:exec -DadditionalJavaArgs="$ADDITIONAL_JAVA_ARGS"

That way the user of the script can add a main class followed by an unlimited number of application arguments.

Tomas F
  • 11
  • 2