How to deploy different jars for different database runtimes with maven? -
i have different maven profiles , spring profiles different databases: mysql, postgresql. setting maven profile adds corresponding dependencies. setting spring profile adds corresponding spring properties @ runtime. i'd maintain 1 code base , deploy 2 different artifacts repository.
i'd generate following jars: ${project.artifactid}-${target.database}-${project.version}
.
i have tried using classifiers seems can not configure deploy plugin them. seems have override properties command line. , approach generated file name be: ${project.artifactid}-${project.version}-${target.database}
(given classifier named after ${target.database}
).
is @ possible configured within pom , issuing standard maven commands overriding profiles?
if not, best approach?
edit: add pom
in summary pom defines per environment profile: dev, int, uat , pro; , per database profiles (orthogonal previous ones): mysql, postgresql. important profiles here database profiles.
<?xml version="1.0" encoding="utf-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<groupid>com.byteflair</groupid> <artifactid>oauth2-server</artifactid> <version>0.1.0-rc1</version> <packaging>jar</packaging> <properties> <start-class>com.byteflair.oauth.server.oauth2serverapp</start-class> <java.version>1.8</java.version> <spring-security.version>4.1.3.release</spring-security.version> <sonar.version>2.7.1</sonar.version> <spock.version>1.1-groovy-2.4-rc-2</spock.version> <keystore.path>${project.build.directory}/keystore.jks</keystore.path> <unit.skip>false</unit.skip> <int.skip>false</int.skip> <docker.skip>false</docker.skip> </properties> <profiles> <profile> <id>mysql</id> <activation> <property> <name>spring.profiles.active</name> <value>mysql</value> </property> </activation> <properties> <classifier>mysql</classifier> </properties> <build> <plugins> <plugin> <groupid>io.fabric8</groupid> <artifactid>docker-maven-plugin</artifactid> <version>0.15.16</version> <configuration> <images> <image> <!--docker run --name mensosdb -p 27017:27017 -d mongo:3.0.8--> <alias>oauthdb</alias> <name>mysql:5.5</name> <run> <env> <mysql_root_password>password</mysql_root_password> <mysql_user>oauth_server</mysql_user> <mysql_password>password</mysql_password> <mysql_database>oauth_db</mysql_database> </env> <ports> <port>3306:3306</port> </ports> <wait> <log>mysqld: ready connections.</log> <time>20000</time> </wait> </run> </image> </images> <skip>${docker.skip}</skip> </configuration> <executions> <execution> <id>start-containers</id> <phase>pre-integration-test</phase> <goals> <goal>build</goal> <goal>start</goal> </goals> </execution> <execution> <id>stop-containers</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.36</version> </dependency> </dependencies> </profile> <profile> <id>postgresql</id> <activation> <property> <name>spring.profiles.active</name> <value>postgresql</value> </property> </activation> <properties> <classifier>postgresql</classifier> </properties> <build> <plugins> <plugin> <groupid>io.fabric8</groupid> <artifactid>docker-maven-plugin</artifactid> <version>0.15.16</version> <configuration> <images> <image> <!--docker run --name mensosdb -p 27017:27017 -d mongo:3.0.8--> <alias>oauthdb</alias> <name>postgres:9.5</name> <run> <env> <postgres_user>oauth_server</postgres_user> <postgres_password>password</postgres_password> <postgres_db>oauth_db</postgres_db> </env> <ports> <port>5432:5432</port> </ports> <wait> <log>database system ready accept connections</log> <time>20000</time> </wait> </run> </image> </images> <skip>${docker.skip}</skip> </configuration> <executions> <execution> <id>start-containers</id> <phase>pre-integration-test</phase> <goals> <goal>build</goal> <goal>start</goal> </goals> </execution> <execution> <id>stop-containers</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupid>org.postgresql</groupid> <artifactid>postgresql</artifactid> <version>9.4.1211</version> </dependency> </dependencies> </profile> <profile> <id>dev</id> <activation> <property> <name>spring.profiles.active</name> <value>dev</value> </property> </activation> <properties> <unit.skip>false</unit.skip> <int.skip>false</int.skip> <docker.skip>false</docker.skip> </properties> </profile> <profile> <id>int</id> <activation> <property> <name>spring.profiles.active</name> <value>int</value> </property> </activation> <properties> <unit.skip>false</unit.skip> <int.skip>false</int.skip> <docker.skip>true</docker.skip> </properties> </profile> <profile> <id>uat</id> <activation> <property> <name>spring.profiles.active</name> <value>uat</value> </property> </activation> <properties> <unit.skip>false</unit.skip> <int.skip>false</int.skip> <docker.skip>true</docker.skip> </properties> </profile> <profile> <id>pro</id> <activation> <property> <name>spring.profiles.active</name> <value>pro</value> </property> </activation> <properties> <unit.skip>false</unit.skip> <int.skip>false</int.skip> <docker.skip>true</docker.skip> </properties> </profile> </profiles> <parent> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-parent</artifactid> <version>1.4.0.release</version> </parent> <build> <plugins> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>keytool-maven-plugin</artifactid> <version>1.5</version> <executions> <execution> <goals> <goal>generatekeypair</goal> </goals> <phase>generate-resources</phase> </execution> </executions> <configuration> <keystore>${keystore.path}</keystore> <dname>ou=development, o=byteflair, l=madrid s=madrid, c=spain</dname> <keyalg>rsa</keyalg> <storepass>password</storepass> <keypass>password</keypass> <alias>dev_oauth_jwt_key</alias> <skipifexist>true</skipifexist> </configuration> </plugin> <plugin> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> </plugin> <plugin> <groupid>org.projectlombok</groupid> <artifactid>lombok-maven-plugin</artifactid> <version>1.16.6.1</version> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>3.1</version> <configuration> <compilerversion>1.8</compilerversion> <source>1.8</source> <target>1.8</target> <encoding>utf8</encoding> </configuration> </plugin> <plugin> <!-- gmavenplus plugin used compile groovy code. learn more plugin, visit https://github.com/groovy/gmavenplus/wiki --> <groupid>org.codehaus.gmavenplus</groupid> <artifactid>gmavenplus-plugin</artifactid> <version>1.4</version> <executions> <execution> <goals> <goal>compile</goal> <goal>testcompile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.17</version> <configuration> <systemproperties> <user.timezone>utc</user.timezone> </systemproperties> <includes> <include>**/*test.java</include> <include>**/*spec.java</include> </includes> <skiptests>${unit.skip}</skiptests> </configuration> <executions> <execution> <goals> <goal>test</goal> <goal>test</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-failsafe-plugin</artifactid> <version>2.17</version> <configuration> <skiptests>${int.skip}</skiptests> <systemproperties> <user.timezone>utc</user.timezone> </systemproperties> <includes> <include>**/*it.java</include> </includes> </configuration> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.jacoco</groupid> <artifactid>jacoco-maven-plugin</artifactid> <version>0.7.2.201409121644</version> <executions> <execution> <id>default-prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>default-report</id> <phase>prepare-package</phase> <goals> <goal>report</goal> </goals> </execution> <execution> <id>default-prepare-agent-integration</id> <goals> <goal>prepare-agent-integration</goal> </goals> </execution> <execution> <id>default-report-integration</id> <goals> <goal>report-integration</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>sonar-maven-plugin</artifactid> <version>${sonar.version}</version> </plugin> <plugin> <artifactid>maven-jar-plugin</artifactid> <executions> <execution> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <classifier>${classifier}</classifier> </configuration> </execution> </executions> </plugin> <plugin> <artifactid>maven-deploy-plugin</artifactid> <executions> <execution> <phase>deploy</phase> <goals> <goal>deploy</goal> </goals> <configuration> <classifier>${classifier}</classifier> </configuration> </execution> </executions> </plugin> </plugins> </build> <distributionmanagement> <repository> <id>byteflair</id> <name>releases</name> <url>https://nexus.byteflair.com/repository/maven-releases</url> </repository> <snapshotrepository> <id>byteflair</id> <name>snapshot</name> <url>https://nexus.byteflair.com/repository/maven-snapshots</url> </snapshotrepository> </distributionmanagement> <dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-security</artifactid> </dependency> <dependency> <groupid>org.springframework.security.oauth</groupid> <artifactid>spring-security-oauth2</artifactid> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-jwt</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-web</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-freemarker</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-actuator</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-data-rest</artifactid> </dependency> <dependency> <groupid>org.springframework.plugin</groupid> <artifactid>spring-plugin-core</artifactid> </dependency> <dependency> <groupid>org.projectlombok</groupid> <artifactid>lombok</artifactid> <version>1.16.6</version> <scope>provided</scope> </dependency> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-test</artifactid> <scope>test</scope> </dependency> <dependency> <groupid>com.jayway.jsonpath</groupid> <artifactid>json-path</artifactid> <version>2.0.0</version> <scope>test</scope> </dependency> <dependency> <groupid>br.com.six2six</groupid> <artifactid>fixture-factory</artifactid> <version>3.0.0</version> <exclusions> <exclusion> <groupid>log4j</groupid> <artifactid>log4j</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-data-jpa</artifactid> </dependency> <dependency> <groupid>io.rest-assured</groupid> <artifactid>rest-assured</artifactid> <version>3.0.0</version> <scope>test</scope> </dependency> <dependency> <groupid>io.rest-assured</groupid> <artifactid>json-path</artifactid> <version>3.0.0</version> <scope>test</scope> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-test</artifactid> <scope>test</scope> </dependency> <!-- mandatory dependencies using spock --> <dependency> <groupid>org.spockframework</groupid> <artifactid>spock-core</artifactid> <version>${spock.version}</version> <scope>test</scope> </dependency> <!-- optional dependencies using spock --> <dependency> <groupid>org.spockframework</groupid> <artifactid>spock-spring</artifactid> <version>${spock.version}</version> <scope>test</scope> </dependency> <dependency> <!-- use specific groovy version rather 1 specified spock-core --> <groupid>org.codehaus.groovy</groupid> <artifactid>groovy-all</artifactid> <version>2.4.1</version> </dependency> <dependency> <groupid>cglib</groupid> <artifactid>cglib-nodep</artifactid> <version>release</version> </dependency> </dependencies> <dependencymanagement> <dependencies> <dependency> <groupid>org.springframework.data</groupid> <artifactid>spring-data-releasetrain</artifactid> <version>hopper-sr2</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-bom</artifactid> <version>${spring-security.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencymanagement>
Comments
Post a Comment