<build> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <configuration> <!-- 更改 output 目錄 --> <buildOutputDirectory>war/WEB-INF/classes</buildOutputDirectory> <!-- 讓產生的 .classpath 包含 source jar --> <downloadSources>true</downloadSources> <!-- 自訂使用的 JRE --> <classpathContainers> <classpathContainer>com.google.appengine.eclipse.core.GAE_CONTAINER</classpathContainer> <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer> </classpathContainers> </configuration> </plugin> </plugins> </build>
在 .classpath 製造出 <classpathentry kind="src" path="src"/>
先加上以下的設定:
<build> ... <sourceDirectory>src</sourceDirectory> ... </build>這樣有兩個問題,第一個會產生 <classpathentry kind="src" path="src" include="**/*.java"/> ,多一個麻煩的 include,第二個更麻煩,導致 mvn compile 會出現以下的錯誤:
... generics are not supported in -source 1.3 (use -source 5 or higher to enable generics)加上 resouce 的設定消除 include:
<build> ... <resource> <directory>src</directory> <!-- 因為 src 目錄下也有 java 檔,所以要加這個 filter,不然 java 檔也會被搬到 classes 目錄下 --> <includes> <include>**/*.xml</include> <include>**/*.properties</include> </includes> </resource> ... </build>就可以在 .classpath 製造出 <classpathentry kind="src" path="src"/> 這段,但是 mvn compile 仍會出錯。
最後加上下面這段設定就沒問題了!
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <includes> <include>src/**</include> </includes> </configuration> </plugin>
在執行 mvn resources:resources 時會出現一個警告訊息:
[WARNING] Using platform encoding (MS950 actually) to copy filtered resources, i.e. build is platform dependent!可以加上下面的設定:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>MS950</encoding> </configuration> </plugin>
在執行 mvn war:war 時會出現一個警告訊息:
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored (webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')在 maven-war-plugin 加上 packagingExcludes 就可以消除了。
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <warSourceDirectory>war</warSourceDirectory> <packagingExcludes>WEB-INF/web.xml</packagingExcludes> </configuration> </plugin>
沒有留言:
張貼留言