我的项目存在编译问题。这是用Tapestry构建的旧Web应用程序。
我的问题是具有Java扩展名的文件位于“ src / main / resources” 目录下。
我在Eclipse上使用“运行方式> Maven安装”。当我从Eclipse构建项目时,那些扩展名为“ .java”的文件将被编译并复制到“ WEB-INF / classes / [package] / [name] .class” 。这就是我想要的行为。
但是当我从命令行执行“ mvm install”时,不会发生这种情况。
这是我的pom.xml
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.tapestry</groupId>
<artifactId>project</artifactId>
<version>1.0-PROD</version>
<packaging>war</packaging>
<name>project</name>
<dependencies>
<dependency>
<groupId>fr.project.ws.bms</groupId>
<artifactId>bms-cxf-rt-bindings</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/bms-cxf-rt-bindings-1.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>fr.project.ws.bms</groupId>
<artifactId>bms-bc-api</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/bms-bc-api-1.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>fr.project.ws.bms</groupId>
<artifactId>bms-bc-det-api</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/bms-bc-det-api-1.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-core</artifactId>
<version>${tapestry-release-version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>upsa</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<optimize>true</optimize>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.0-beta-6</version>
<configuration>
<outputEncoding>iso-8859-15</outputEncoding>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<!-- Adds a report detailing the components, mixins and base classes defined
by this module. -->
<plugins>
<plugin>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-component-report</artifactId>
<version>${tapestry-release-version}</version>
<configuration>
<rootPackage>org.apache.tapestry.upsa</rootPackage>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<minmemory>128m</minmemory>
<maxmemory>512m</maxmemory>
</configuration>
</plugin>
</plugins>
<!-- Adds a report detailing the components, mixins and base classes defined
by this module. -->
</reporting>
<repositories>
<repository>
<id>tapestry-snapshots</id>
<url>http://tapestry.formos.com/maven-snapshot-repository/</url>
</repository>
<repository>
<id>codehaus.snapshots</id>
<url>http://snapshots.repository.codehaus.org</url>
</repository>
<!-- For access to the selenium JARs. -->
<repository>
<id>openqa</id>
<name>OpenQA Maven Repository</name>
<url>http://maven.openqa.org/</url>
</repository>
<repository>
<id>localhost.nu</id>
<url>http://www.localhost.nu/java/mvn</url>
</repository>
</repositories>
<pluginRepositories>
<!-- As above, this can be commented out when access to the snapshot version
of a Tapestry Maven plugin is not required. -->
<pluginRepository>
<id>tapestry-snapshots</id>
<url>http://tapestry.formos.com/maven-snapshot-repository/</url>
</pluginRepository>
</pluginRepositories>
<properties>
<tapestry-release-version>5.0.13</tapestry-release-version>
</properties>
</project>
所以主要问题是如何指示Maven在src / main / resources中编译.java文件并将其放置在“ WEB-INF / classes / [package] / [name] .class” 之后。
我已经尝试了:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>default-copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${project.build.directory}/${project.artifactId}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
但不这样做。