3

私はjscssの集約にwro4jを使用しています。そのため、私は自分のjsファイルを操作し、maven ビルド時にwro4jを実行して、必要な固有のjsファイルを作成します。

pom.xmlからのプロファイル(何かを見つけるための URL など、環境に関連するもの) に基づくいくつかの変数を持つjsファイルが 1 つあります。

アプリケーションをビルドすると、warファイル内にjsファイル内の置換された変数が表示されます。しかし、wro4jのプラグインが集約されたjsファイルを作成すると、ターゲットフォルダーからではなくwebapps/jsからファイルが取得されるため(これは正しいことです)、集約されたjsファイルには、置換された変数ではなく式変数が含まれます。

wro4jプラグインの後に実行するようにフィルタリングの実行を延期したいと考えています。可能です?

これらは、jsファイル ( global.jsと呼ばれる)の変数です。

var mvnProfileEnvName = "${environment.name}";
var mvnProfileFullSearchUrl = "${full.search.url}";

そして、pom.xmlに次のコードがあります

<profiles>
  <profile>
    <id>dev</id>
    <properties>
      <environment.name>dev</environment.name>
      <full.search.url>url/for/dev</full.search.url>
    </properties>
  </profile>
  <profile>
    <id>test</id>
    <properties>
      <environment.name>test</environment.name>
      <full.search.url>url/for/test<full.search.url>
    </properties>
  </profile>
  <profile>
    <id>prod</id>
    <properties>
      <environment.name>prod</environment.name>
      <full.search.url>url/for/prod</full.search.url>
    </properties>
  </profile>
</profiles>
<build>
  <resources>
    <resource>
      <directory>${basedir}/src/main/webapp/js</directory>
      <filtering>true</filtering>
      <includes>
        <include>global.js</include>
      </includes>
    </resource>
    <resource>
      <directory>${basedir}/src/main/webapp/wro</directory>
      <filtering>true</filtering>
    </resource>
  </resources>

  </plugins>
    <plugin>
      <groupId>ro.isdc.wro4j</groupId>
      <artifactId>wro4j-maven-plugin</artifactId>
      <version>${wro4j.version}</version>
      <executions>
        <execution>
          <phase>prepare-package</phase>
          <goals>
            <goal>run</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <minimize>true</minimize>
        <jsDestinationFolder>${basedir}/src/main/webapp/wro/js/</jsDestinationFolder>
        <cssDestinationFolder>${basedir}/src/main/webapp/wro/css/</cssDestinationFolder>
      </configuration>
    </plugin>
  </plugins>
<build>
4

1 に答える 1

2

フィルタリングを有効にして、設定を試してから、後のフェーズで<filtering>false</filtering>の実行を手動で構成することができます。maven-resources-pluginこれを wo4j プラグイン宣言の後に配置します。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <executions>
    <execution>
      <id>filter-resources</id>
      <phase>prepare-package</phase>
      <goals><goal>resources</goal></goals>
    </execution>
  </executions>
</plugin>

http://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html

于 2013-06-16T03:11:08.927 に答える