[ 
https://issues.apache.org/jira/browse/MNG-6508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16760148#comment-16760148
 ] 

Karl Heinz Marbaise commented on MNG-6508:
------------------------------------------

Based on the log and your configuration the build in Travis simply failed cause 
it's trying to use the postrgres driver which is working as expected cause the 
activeByDefault:true is set for the postgres profile. 
And the {{connection.properties}} is use from {{src/main/resources}} in cases 
where there is no other file like this on the classpath which is usually the 
case except someone places an other one on the classpath during the tests 
phase. But in this case the activeByDefault controls which driver is being 
used. Apart from the above this is not a bug it's intended behavour. 
Furthermore such question should be done on the users mailing list first. Apart 
from that I strongly recommend never to change/having dependencies controlled 
by profiles. If you need different things it would be better to create 
separated modules which have different dependencies.

So I will close this. If you have further details what the expected behaviour 
is etc. please reopen this issue or ask on the users mailing list. 

> 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, Ubuntu 14.04, 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)

Reply via email to