You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Tsukanov Ilya Vladimirovich (JIRA)" <ji...@apache.org> on 2018/11/07 22:03:00 UTC

[jira] [Updated] (MNG-6508) maven profile overwrites test resources

     [ https://issues.apache.org/jira/browse/MNG-6508?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tsukanov Ilya Vladimirovich updated MNG-6508:
---------------------------------------------
    Environment: Windows 8.1, linux, jdk1.8.0_191  (was: Windows 8.1, linux)

> maven profile overwrites test resources
> ---------------------------------------
>
>                 Key: MNG-6508
>                 URL: https://issues.apache.org/jira/browse/MNG-6508
>             Project: Maven
>          Issue Type: Bug
>          Components: Profiles
>    Affects Versions: 3.3.9, 3.6.0
>         Environment: Windows 8.1, linux, jdk1.8.0_191
>            Reporter: Tsukanov Ilya Vladimirovich
>            Priority: Critical
>
> 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.
> {code:xml}
> <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>
> {code}
> This profile overwrites my connection.properties from src/test/resources on src/main/resources.
> connection.properties from src/test/resources
> {noformat}
> database.driver_class_name=org.h2.Driver
> database.url=jdbc:h2:mem:h2db;DB_CLOSE_DELAY=-1
> database.username=sa
> database.password=sa
> {noformat}
> connection.properties from src/main/resources
> {noformat}
> database.driver_class_name=${database.driver_class_name}
> database.url=${database.url}
> database.username=${database.username}
> database.password=${database.password}
> {noformat}
> I wrote testResources tag in build tag of root pom file and in build tag of profile tag such as
> {code:xml}
> <testResources>
>     <testResource>
>         <directory>${project.basedir}/src/test/resources</directory>
>         <filtering>true</filtering>
>     </testResource>
> </testResources>
> {code}
> 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



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)