2

maven を使用して、文字列 %APP_NAME% を jdbc.properties の環境変数に置き換えようとしています。次の構成があります。

<pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.google.code.maven-replacer-plugin</groupId>
                    <artifactId>replacer</artifactId>
                    <version>1.5.2</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>replace</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <basedir>${project.build.directory}/classes</basedir>
                        <includes>
                            <include>jdbc.properties</include>
                        </includes>
                        <replacements>
                            <replacement>
                                <token>%APP_NAME%</token>
                                <value>${env.BRANCH_NAME}</value>
                            </replacement>
                        </replacements>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                    <executions>
                        <execution>
                            <!-- First step is to disable the default-war build step. -->
                            <id>default-war</id>
                            <phase>none</phase>
                        </execution>
                        <execution>
                            <!-- Second step is to create an exploded war. Done in prepare-package -->
                            <id>war-exploded</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>exploded</goal>
                            </goals>
                        </execution>
                        <execution>
                            <!-- Last step is to make sure that the war is built in the package 
                                phase -->
                            <id>custom-war</id>
                            <phase>package</phase>
                            <goals>
                                <goal>war</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-eclipse-plugin</artifactId>
                    <version>2.9</version>
                    <configuration>
                        <additionalProjectnatures>
                            <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                        </additionalProjectnatures>
                        <additionalBuildcommands>
                            <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                        </additionalBuildcommands>
                        <downloadSources>true</downloadSources>
                        <downloadJavadocs>true</downloadJavadocs>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <!-- <compilerArgument>-Xlint:all</compilerArgument> -->
                        <showWarnings>true</showWarnings>
                        <showDeprecation>true</showDeprecation>
                        <compilerArguments>
                            <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                        </compilerArguments>
                    </configuration>
                </plugin>   
        </plugins>
</pluginManagement>

私が呼び出すとき:

mvn clean package

また

mvn clean install

置換プラグインは呼び出されません。誰でもその理由と、それを機能させるために何ができるかを説明できますか? または、replacer が将来の戦争プラグインと互換性がない場合、戦争を構築する前に jdbc.properties の文字列を置き換える他の方法を誰かが説明できますか? ant プラグインも見ましたが、同じ構成では呼び出されません..以下の例..

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version> 
    <executions>
        <execution>
            <id>deploy-ui</id>
            <phase>package</phase>
            <inherited>false</inherited> 
            <configuration>
                <tasks>
                    <replace dir="${basedir}/src/main/resources">
                        <include name="**/jdbc.properties" />
                        <replacefilter token="%APP_NAME%" value="${env.BRANCH_NAME}"/>
                    </replace>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals> 
        </execution>
    </executions>
</plugin>
4

1 に答える 1