问题
I am using Liquibase (via its Maven plugin) to handle database migrations.
However not all Liquibase features are available via Maven. One in particular, Generate Changelog, is only available via the command line (using the downloadable liquibase.jar) with a command like this:
java -jar liquibase.jar \
--driver=oracle.jdbc.OracleDriver \
--classpath=\path\to\classes:jdbcdriver.jar \
--changeLogFile=com/example/db.changelog.xml \
--url="jdbc:oracle:thin:@localhost:1521:XE" \
--username=scott \
--password=tiger \
generateChangeLog
How can I execute this command via Maven, portably? That is, I do not want to have to add the liquibase.jar file to my project structure.
Instead, I would like to list it as a dependency (I could manually add the jar to my local repository or Nexus proxy) and then reference it when using something like the Exec Maven Plugin's exec:java
or exec:exec
goals, but I can't see how to do this using an executable jar with those goals. :(
Any suggestions would be much appreciated.
Thanks!
回答1:
I don't know, but may be this will help you.
Try to use maven exec plugin and put as a mainClass configuration param this: liquibase.integration.commandline.Main
I get it from MANIFEST.MF from your jar file
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
...
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>liquibase.integration.commandline.Main</mainClass>
<arguments>
<argument>--driver=oracle.jdbc.OracleDriver</argument>
<argument>--changeLogFile=com/example/db.changelog.xml</argument>
...
</arguments>
</configuration>
</plugin>
来源:https://stackoverflow.com/questions/16315260/how-to-execute-a-third-party-jar-using-maven