Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Not A Problem
-
3.3.9, 3.6.0
-
None
-
None
-
Windows 8.1, Ubuntu 14.04, jdk1.8.0_191
Description
I'm trying to make maven profiles which would use two difference DBMS. DBMS configs are stored in maven profiles. Web App gets settings from file connection.properties in src/main/resources. There is also a similar file with same title connection.properties in src/test/resources and this file should be uploaded only during test lyfecycle maven. Then spring core uses the DBMS connection settings specified in connection.properties.
I have problem with maven profile which overwrites resources such as src/test/resources/connection.properties on src/main/resources/connection.properties from test directory when test lifecycle maven is running.
<profiles> <profile> <id>profile-postgres</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <database.driver_class_name>org.postgresql.Driver</database.driver_class_name> <database.url>jdbc:postgresql://127.0.0.1:5432/bulls_and_cows</database.url> <database.username>postgres</database.username> <database.password>postgres</database.password> <jpa.show_sql>true</jpa.show_sql> <jpa.generate_ddl>true</jpa.generate_ddl> <jpa.database>POSTGRESQL</jpa.database> <jpa.database_platform>org.hibernate.dialect.PostgreSQL95Dialect</jpa.database_platform> <jpa.hibernate.hbm2ddl.auto>validate</jpa.hibernate.hbm2ddl.auto> <jpa.hibernate.format_sql>false</jpa.hibernate.format_sql> <h2.scope>test</h2.scope> </properties> <dependencies> <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.1</version> </dependency> </dependencies> </profile> <profile> <id>profile-h2</id> <activation> <activeByDefault>false</activeByDefault> </activation> <properties> <database.driver_class_name>org.h2.Driver</database.driver_class_name> <database.url>jdbc:h2:mem:h2db;DB_CLOSE_DELAY=-1</database.url> <database.username>sa</database.username> <database.password>sa</database.password> <jpa.show_sql>true</jpa.show_sql> <jpa.generate_ddl>true</jpa.generate_ddl> <jpa.database>H2</jpa.database> <jpa.database_platform>org.hibernate.dialect.H2Dialect</jpa.database_platform> <jpa.hibernate.hbm2ddl.auto>create-drop</jpa.hibernate.hbm2ddl.auto> <jpa.hibernate.format_sql>false</jpa.hibernate.format_sql> <h2.scope>compile</h2.scope> </properties> </profile> </profiles>
This profile overwrites my connection.properties from src/test/resources on src/main/resources.
connection.properties from src/test/resources
database.driver_class_name=org.h2.Driver database.url=jdbc:h2:mem:h2db;DB_CLOSE_DELAY=-1 database.username=sa database.password=sa
connection.properties from src/main/resources
database.driver_class_name=${database.driver_class_name} database.url=${database.url} database.username=${database.username} database.password=${database.password}
I wrote testResources tag in build tag of root pom file and in build tag of profile tag such as
<testResources> <testResource> <directory>${project.basedir}/src/test/resources</directory> <filtering>true</filtering> </testResource> </testResources>
But instead connection.properties from src/main/resources was always used in test lifecycle of maven.
My old failed build where I used profiles from https://travis-ci.org/WeDism/BullsAndCows/builds/449051809.
My repo with master branch https://github.com/WeDism/BullsAndCows/blob/master/pom.xml.
My repo with with_profiles_h2_postgres branch https://github.com/WeDism/BullsAndCows/blob/with_profiles_h2_postgres/pom.xml
Profile profile-postgres should be main such as activeByDefault = true