我有一个问题,直到现在才确定原因。
我有一个包含多个模块的 Maven 项目。这些模块之一是 web 服务客户端。
所以,在开发过程中,在maven中运行安装时,需要访问本地服务器来生成客户端。当我运行插件来生成项目的发布时,客户端应该指向生产服务器。
为此,我设置了一个关键属性 ${server.address},它用于在生成客户端时指向服务器。有一个配置文件,当它处于活动状态时,此密钥属性会将地址重写到生产服务器。
这是怎么回事?运行 mvn install 生成正确,即指向本地服务器。当我使用命令 mvn release:prepare -B release:perform -Denv=prd 生成发行版时,并没有按应有的方式重写变量。
奇怪的是,如果我运行 mvn install -Denv=prd,它会正确生成,指向生产服务器。
有人可以告诉我在发布周期中要改变什么来工作吗?
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<server.address>http://localhost:8080</server.address>
</properties>
<profiles>
<profile>
<id>prd</id>
<activation>
<property>
<name>env</name>
<value>prd</value>
</property>
</activation>
<properties>
<server.address>http://srvprd009:8080</server.address>
</properties>
</profile>
</profiles>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testSourceDirectory>src/test/java</testSourceDirectory>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
<execution>
<id>generate-client</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>src/main/gen</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${server.address}/services/utilities?wsdl</wsdl>
<extraargs>
<extraarg>-p</extraarg>
<extraarg>${project.package}</extraarg>
<extraarg>-impl</extraarg>
<extraarg>-verbose</extraarg>
<extraarg>-frontend</extraarg>
<extraarg>jaxws21</extraarg>
<extraarg>-xjc-XhashCode</extraarg>
<extraarg>-xjc-Xequals</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.4</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven-clean-plugin.version}</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/gen</directory>
<includes>
<include>**/*.*</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ts-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>corporate-tools.fragmental.security</groupId>
<artifactId>basic-ws-client</artifactId>
<version>${fragmental.version}</version>
</dependency>
<!-- JEE -->
<dependency>
<groupId>javax.j2ee</groupId>
<artifactId>j2ee</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
<!-- JAX-WS -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxws.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>${jaxws.version}</version>
<exclusions>
<exclusion>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
</exclusion>
<exclusion>
<artifactId>jsr250-api</artifactId>
<groupId>javax.annotation</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>