1

純粋な Maven (コマンドラインを使用) と Eclipse (Juno) の両方で、lesscss-maven-pluginを使用して LESS CSS ファイルをコンパイルしようとしています。

lesscss-maven-plugin では、出力ディレクトリを定義する必要がありますが、Eclipse では WTP がサーバー (JBoss) からファイルをコピーすることに気付きましたtarget/m2e-wtpが、このディレクトリは Maven の war プラグインによって無視されます。

Mavenプロファイルで目標を達成することに成功しました。Eclipsem2eでは、プロジェクト設定で構成されたプロファイルを使用するため、Eclipseでビルドするかどうかに応じて2つの異なる宛先フォルダーを定義できます。

ここに私の pom.xml があります:

<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>com.dgadev.motd</groupId>
    <artifactId>motd</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <properties>
        <maven.compiler.source>7</maven.compiler.source>
        <maven.compiler.target>7</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
            ....
    </dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.lesscss</groupId>
            <artifactId>lesscss-maven-plugin</artifactId>
            <version>1.3.3</version>
            <configuration>
                <outputDirectory>${project.build.directory}/resources/css</outputDirectory>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <id>m2e</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.lesscss</groupId>
                    <artifactId>lesscss-maven-plugin</artifactId>
                    <version>1.3.3</version>
                    <configuration>
                        <outputDirectory>${project.build.directory}/m2e-wtp/web-resources/resources/css</outputDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

これは機能しますが、プロファイルのトリックなしでこれを行うより良い方法はありますか?

4

2 に答える 2

1

私は別の少ないコンパイラで別の解決策を見つけました: wro4j. このコンパイラには、maven プラグインと m2e プラグインの両方が存在します。さらに、(ブーストラップを構築するための) チュートリアルがここにあります: m2e-wro4j

于 2013-05-04T16:17:36.107 に答える