2012-09-03 27 views
9

Tôi muốn chuyển một số biến hệ thống cho bản dựng Maven. Nếu tôi sử dụng mvn clean install -Dfirst.variable=value -Dsecond.variable=second.value mọi thứ đều ổn. Nhưng cấu hình này trong pom.xml không hoạt động:Chuyển các biến hệ thống với maven-surefire-plugin trong Maven

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.12.3</version> 
      <executions> 
       <execution> 
        <id>tests</id> 
        <phase>test</phase> 
        <goals> 
         <goal>test</goal> 
        </goals> 
        <configuration> 
         <includes> 
          <include>**/*Test.java</include> 
         </includes> 
         <systemPropertyVariables> 
          <first.variable>${value}</first.variable> 
          <second.variable>${second.value}</second.variable> 
         </systemPropertyVariables> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

Tôi cố gắng để sử dụng cấu hình này mà không , <phase/><goals> nhưng nó đã không giúp đỡ. Có khả năng plugin không chạy không? Ngay cả các giá trị hardcoded của các biến này không vượt qua. Nếu vậy, giải pháp có thể xảy ra là gì? Cảm ơn trước.

Trả lời

8

Bạn không cần phải tạo một <execution/>. Cách dễ dàng:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <configuration> 
     <systemPropertyVariables> 
     <my.property>propertyValue</my.property> 
     </systemPropertyVariables> 
    </configuration> 
</plugin> 
+0

Cảm ơn rất nhiều! Tôi khá chắc chắn tôi thấy một mẫu mã với , đó là nghĩa vụ phải làm việc tốt. Lý do của một hành vi như vậy là gì? –

Các vấn đề liên quan