Guest User

Untitled

a guest
Nov 28th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. ...
  2. <groupId>lib.example</groupId>
  3. <artifactId>jdbc</artifactId>
  4. <version>1.0.0</version>
  5. <packaging>jar</packaging>
  6. ...
  7. <properties>
  8. ...
  9. <mysql.port>3306</mysql.port>
  10. <mysql.database>testDb</mysql.database>
  11. <mysql.user>root</mysql.user>
  12. <mysql.pass>password</mysql.pass>
  13. </properties>
  14. ...
  15. <build>
  16. ...
  17. <plugins>
  18. ...
  19. <plugin>
  20. <groupId>org.codehaus.mojo</groupId>
  21. <artifactId>sql-maven-plugin</artifactId>
  22. <version>1.5</version>
  23. <dependencies>
  24. <dependency>
  25. <groupId>mysql</groupId>
  26. <artifactId>mysql-connector-java</artifactId>
  27. <version>5.1.44</version>
  28. </dependency>
  29. </dependencies>
  30. <configuration>
  31. <driver>com.mysql.jdbc.Driver</driver>
  32. <url>jdbc:mysql://${mysql.host}:${mysql.port}/${mysql.database}?useSSL=false</url>
  33. <username>${mysql.user}</username>
  34. <password>${mysql.pass}</password>
  35. <settingsKey>sensibleKey</settingsKey>
  36. <!--all executions are ignored if -Dmaven.test.skip=true-->
  37. <skip>${maven.test.skip}</skip>
  38. </configuration>
  39. <executions>
  40. <execution>
  41. <id>create-db</id>
  42. <phase>process-test-resources</phase>
  43. <goals>
  44. <goal>execute</goal>
  45. </goals>
  46. <configuration>
  47. <url>jdbc:mysql://${mysql.host}:${mysql.port}?useSSL=false</url>
  48. <autocommit>true</autocommit>
  49. <sqlCommand>create database if not exists `${mysql.database}`</sqlCommand>
  50. </configuration>
  51. </execution>
  52. </executions>
  53. </plugin>
  54. </plugins>
  55. </build>
  56.  
  57. <groupId>com.example</groupId>
  58. <artifactId>project</artifactId>
  59. <version>0.0.1</version>
  60. ...
  61. <properties>
  62. ...
  63. <mysql.port>3306</mysql.port>
  64. <mysql.database>testDb</mysql.database>
  65. <mysql.user>root</mysql.user>
  66. <mysql.pass>password</mysql.pass>
  67. </properties>
  68. ...
  69. <dependencies>
  70. ...
  71. <dependency>
  72. <groupId>lib.example</groupId>
  73. <artifactId>jdbc</artifactId>
  74. <version>1.0.0</version>
  75. </dependency>
  76. ...
  77. </dependencies>
  78. ...
  79. <build>
  80. <finalName>${project.artifactId}</finalName>
  81. <plugins>
  82. ...
  83. <plugin>
  84. <groupId>org.codehaus.mojo</groupId>
  85. <artifactId>sql-maven-plugin</artifactId>
  86. <version>1.5</version>
  87.  
  88. <dependencies>
  89. <dependency>
  90. <groupId>mysql</groupId>
  91. <artifactId>mysql-connector-java</artifactId>
  92. <version>5.1.44</version>
  93. </dependency>
  94. </dependencies>
  95. <configuration>
  96. <driver>com.mysql.jdbc.Driver</driver>
  97. <url>jdbc:mysql://${mysql.host}:${mysql.port}?useSSL=false</url>
  98. <username>${mysql.user}</username>
  99. <password>${mysql.pass}</password>
  100. <settingsKey>sensibleKey</settingsKey>
  101. <!--all executions are ignored if -Dmaven.test.skip=true-->
  102. <skip>${maven.test.skip}</skip>
  103. </configuration>
  104. <executions>
  105. <execution>
  106. <id>drop-db-before-test-if-any</id>
  107. <phase>process-test-resources</phase>
  108. <goals>
  109. <goal>execute</goal>
  110. </goals>
  111. <configuration>
  112. <url>jdbc:mysql://${mysql.host}:${mysql.port}?useSSL=false</url>
  113. <autocommit>true</autocommit>
  114. <sqlCommand>drop database if exists `${mysql.database}`</sqlCommand>
  115. <sqlCommand>create database `${mysql.database}`</sqlCommand>
  116. </configuration>
  117. </execution>
  118. </executions>
  119. </plugin>
  120. </plugins>
  121. </build>
Add Comment
Please, Sign In to add comment