私はMaven 3を使用しています。私はJSPファイルを持ち、別のプロジェクトに格納された "グローバル" JSPファイルを使用するプロジェクトに直面しています。これはmaven-war-pluginとwebResources
を使用するとうまく動作します。すべてのJSPファイルがWARファイルに格納されます。Maven:JspCは外部JSPファイルを使用する必要があります
新しいアイデアは、すべてのJSPをあらかじめコンパイルすることです。明白な選択はjspc-maven-pluginを使用することです。ただし、プロジェクトのローカルJSPをコンパイルするときに外部JSPは含まれません。
はここpom.xml
からの抜粋です:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<warName>${pom.groupId}.${pom.artifactId}-0.0.1-SNAPSHOT</warName>
<webXml>${basedir}/target/jspweb.xml</webXml>
<webResources>
<resource>
<directory>../name.of.external.project/src/global/webapp</directory>
</resource>
</webResources>
</configuration>
</plugin>
エラーがjspGlobal
-directoryは上記<directory>../name.of.external.project/src/global/webapp</directory>
-lineでコピーされますでしょう
[ERROR] Failed to execute goal org.codehaus.mojo:jspc-maven-plugin:1.4.6:compile (jspc) on project internal.project: JSPC Error: file:C:/workspace/name.of.internal.project/src/main/webapp/WEB-INF/views/show.jsp(2,0) File "/WEB-INF/views/../jspGlobal/jsp-declaration.jspf" not found -> [Help 1]
です。
JspCに外部JSPを含めるには何が欠けていますか?
EDIT:prunge'sとRaghuram's inputのおかげで、私はソースとのJavaDocに深く見えました。私は、上記のsources
にはFileSet
が必要であり、ディレクトリのリストを許可していないことに気づいた。 sources
もリストではないので、複数のJSPソースディレクトリをどのように指定できるかはわかりません。私も<plugin>
要素をコピーしようとしましたが、それは助けになりませんでした。現在の状況は次のとおりです。
<plugin>
<groupId>org.codehaus.mojo.jspc</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<version>2.0-alpha-3</version>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<directory>${basedir}/../name.of.external.project/src/global/webapp</directory>
</sources>
<!-- the later mentioned <sources> gets picked
<sources>
<directory>${basedir}/src/main/webapp</directory>
</sources>
-->
<!-- 1.6 doesn't work!? Something lower than 1.5 seems to be the default -->
<source>1.5</source>
<target>1.5</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo.jspc</groupId>
<artifactId>jspc-compiler-tomcat6</artifactId>
<version>2.0-alpha-3</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<warName>${pom.groupId}.${pom.artifactId}-0.0.1-SNAPSHOT</warName>
<webXml>${basedir}/target/jspweb.xml</webXml>
<webResources>
<resource>
<directory>../name.of.external.project/src/global/webapp</directory>
</resource>
</webResources>
</configuration>
</plugin>
これで、外部JSPは現在のプロジェクトのターゲットパスにコンパイルされます。今現在のプロジェクトのJSPをコンパイルする方法が必要です。これはどうすればいいですか?
私が<sources>
を現在のプロジェクトの行に切り替えると、私は前に述べたのと同じエラーになります。
私はそれを試しました。 'jspc-compiler-tomcat6'への依存関係を追加するだけであれば、同じ出力が行われることになります。 – sjngm
@sjngmなぜ依存関係を追加するのですか?それをプラグインとして追加しようとしましたか? – Dharmaputhiran
@Dharmaputhiran申し訳ありませんが、わかりません。これはずっと前です。 – sjngm