了解如何在某些pom文件中使用maven-enforcer-plugin

时间:2015-01-24 17:54:47

标签: java maven tiles

我正在尝试编译apache tiles,模块tiles-core但是我有以下错误:

  

--- maven-enforcer-plugin:1.2:enforce(enforce-java)@ tiles-core ---规则0:org.apache.maven.plugins.enforcer.RequireJavaVersion失败   with message:检测到的JDK版本:1.8.0不在允许的范围内   [1.7.0-45,1.8)。

项目apache切片包含父级和模块。我正在尝试编译tiles-core。但是,我无法找到并了解在pom文件中使用maven-enforcer-plugin将其关闭的位置。请解释这个插件的使用位置。

父pom文件

<?xml version="1.0"?>
<!--
/*
 * $Id: pom.xml 1626664 2014-09-22 03:28:37Z nlebas $
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
-->
<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/maven-v4_0_0.xsd">

    <parent>
        <artifactId>tiles-master</artifactId>
        <groupId>org.apache.tiles</groupId>
        <version>6</version>
        <relativePath />
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-parent</artifactId>
    <version>3.0.5</version>
    <packaging>pom</packaging>
    <name>Tiles 3</name>
    <description>Tiles 3: A framework for page composition.</description>
    <url>http://tiles.apache.org/framework/</url>
    <scm>
        <connection>scm:svn:http://svn.apache.org/repos/asf/tiles/framework/tags/tiles-parent-3.0.5</connection>
        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/tiles/framework/tags/tiles-parent-3.0.5</developerConnection>
        <url>http://svn.apache.org/viewvc/tiles/framework/tags/tiles-parent-3.0.5</url>
    </scm>

    <ciManagement />

    <modules>
        <module>tiles-api</module>
        <module>tiles-core</module>
        <module>tiles-template</module>
        <module>tiles-servlet</module>
        <module>tiles-jsp</module>
        <module>tiles-freemarker</module>
        <module>tiles-velocity</module>
        <module>tiles-el</module>
        <module>tiles-mvel</module>
        <module>tiles-ognl</module>
        <module>tiles-compat</module>
        <module>tiles-extras</module>
        <module>assembly</module>
        <module>tiles-test-pom</module>
    </modules>

    <issueManagement>
        <system>JIRA</system>
        <url>https://issues.apache.org/jira/browse/TILES</url>
    </issueManagement>

    <distributionManagement>
        <site>
            <id>apache-site</id>
            <url>scm:svn:https://svn.apache.org/repos/asf/tiles/site/staging/framework</url>
        </site>
    </distributionManagement>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.tiles</groupId>
                <artifactId>tiles-api</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.tiles</groupId>
                <artifactId>tiles-core</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.tiles</groupId>
                <artifactId>tiles-servlet</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.tiles</groupId>
                <artifactId>tiles-template</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.velocity</groupId>
                <artifactId>velocity-tools</artifactId>
                <version>2.0</version>
                <exclusions>
                    <exclusion>
                        <artifactId>struts-taglib</artifactId>
                        <groupId>org.apache.struts</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>struts-tiles</artifactId>
                        <groupId>org.apache.struts</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>struts-core</artifactId>
                        <groupId>org.apache.struts</groupId>
                    </exclusion>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                    <exclusion>
                        <artifactId>sslext</artifactId>
                        <groupId>sslext</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>commons-chain</artifactId>
                        <groupId>commons-chain</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>commons-validator</artifactId>
                        <groupId>commons-validator</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>commons-digester</artifactId>
                        <groupId>commons-digester</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>commons-beanutils</artifactId>
                        <groupId>commons-beanutils</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>dom4j</artifactId>
                        <groupId>dom4j</groupId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>commons-digester</groupId>
                <artifactId>commons-digester</artifactId>
                <version>2.0</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.freemarker</groupId>
                <artifactId>freemarker</artifactId>
                <version>2.3.15</version>
            </dependency>

            <dependency>
                <groupId>ognl</groupId>
                <artifactId>ognl</artifactId>
                <version>2.7.3</version>
            </dependency>
            <dependency>
                <groupId>org.mvel</groupId>
                <artifactId>mvel2</artifactId>
                <version>2.0.11</version>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>jsp-api</artifactId>
                <version>2.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.el</groupId>
                <artifactId>el-api</artifactId>
                <version>1.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.7</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.easymock</groupId>
                <artifactId>easymock</artifactId>
                <version>3.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.shale</groupId>
                <artifactId>shale-test</artifactId>
                <version>1.0.5</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.easymock</groupId>
                <artifactId>easymockclassextension</artifactId>
                <version>3.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.6</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
                <version>1.7.6</version>
                <optional>true</optional>
            </dependency>
            <dependency>
                <groupId>org.apache.tiles</groupId>
                <artifactId>tiles-request-api</artifactId>
                <version>${tiles.request.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifestFile>${tiles.manifestfile}</manifestFile>
                            <manifest>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>2.3.7</version>
                    <inherited>true</inherited>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <excludeDependencies>true</excludeDependencies>
                    <manifestLocation>target/osgi</manifestLocation>
                    <instructions>
                        <_nouses>true</_nouses>
                        <Bundle-SymbolicName>${tiles.osgi.symbolicName}</Bundle-SymbolicName>
                        <Export-Package>${tiles.osgi.export}</Export-Package>
                        <Private-Package>${tiles.osgi.private}</Private-Package>
                        <Import-Package>${tiles.osgi.import}</Import-Package>
                        <DynamicImport-Package>${tiles.osgi.dynamicImport}</DynamicImport-Package>
                        <Bundle-DocURL>${project.url}</Bundle-DocURL>
                        <Specification-Title>${project.name}</Specification-Title>
                        <Specification-Version>${project.version}</Specification-Version>
                        <Specification-Vendor>${project.organization.name}</Specification-Vendor>
                        <Implementation-Title>${project.name}</Implementation-Title>
                        <Implementation-Version>${project.version}</Implementation-Version>
                        <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
                        <Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
                    </instructions>
                </configuration>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-scm-publish-plugin</artifactId>
              <extensions>true</extensions>
                <configuration>
                    <pubScmUrl>scm:svn:https://svn.apache.org/repos/asf/tiles/site/staging/framework</pubScmUrl>
                </configuration>
            </plugin>
        </plugins>

        <defaultGoal>install</defaultGoal>
    </build>

    <properties>
        <tiles.osgi.symbolicName>org.apache.${project.artifactId}</tiles.osgi.symbolicName>
        <tiles.osgi.export>org.apache.tiles.*;version=${project.version}</tiles.osgi.export>
        <tiles.osgi.import>*</tiles.osgi.import>
        <tiles.osgi.dynamicImport />
        <tiles.osgi.private />
        <tiles.manifestfile>target/osgi/MANIFEST.MF</tiles.manifestfile>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <tiles.request.version>1.0.6</tiles.request.version>
        <tiles.autotag.version>1.1.0</tiles.autotag.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.5.8</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>apache-release</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-install-plugin</artifactId>
                        <configuration>
                            <createChecksum>true</createChecksum>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>rat-maven-plugin</artifactId>
                        <version>1.0-alpha-3</version>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                                <configuration>
                                    <addDefaultLicenseMatchers>false</addDefaultLicenseMatchers>
                                    <licenseMatchers>
                                        <classNames>
                                            <className>rat.analysis.license.ApacheSoftwareLicense20</className>
                                        </classNames>
                                    </licenseMatchers>
                                    <includes>
                                        <include>pom.xml</include>
                                        <include>src/**</include>
                                    </includes>
                                    <excludes>
                                        <exclude>**/*LICENSE.txt</exclude>
                                        <exclude>**/*MANIFEST.MF</exclude>
                                    </excludes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>linkcheck</id>
            <reporting>
                <plugins>
                    <plugin>
                        <artifactId>maven-linkcheck-plugin</artifactId>
                        <version>1.1</version>
                        <configuration>
                            <excludedLinks>
                                <excludedLink>/*</excludedLink>
                                <excludedLink>**/index.html</excludedLink>
                                <excludedLink>**/logo.png</excludedLink>
                                <excludedLink>**/tiles-jsp/tagreference.html</excludedLink>
                            </excludedLinks>
                        </configuration>
                    </plugin>
                </plugins>
            </reporting>
        </profile>
    </profiles>
</project>

Tiles核心pom文件

<?xml version="1.0"?>
<!--
/*
 * $Id: pom.xml 1626664 2014-09-22 03:28:37Z nlebas $
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
-->
<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/maven-v4_0_0.xsd">

  <parent>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-parent</artifactId>
    <version>3.0.5</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <artifactId>tiles-core</artifactId>
  <packaging>jar</packaging>
  <name>Tiles - Core Library</name>
  <description>Tiles Core Library, including basic implementation of the APIs.
  </description>

  <properties>
      <tiles.osgi.symbolicName>org.apache.tiles.core</tiles.osgi.symbolicName>
  </properties>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>LICENSE.txt</exclude>
          <exclude>NOTICE.txt</exclude>
        </excludes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>LICENSE.txt</include>
          <include>NOTICE.txt</include>
        </includes>
        <targetPath>META-INF</targetPath>
      </resource>
    </resources>
    <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
      </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>net.sf.dtddoc</groupId>
        <artifactId>dtddoc-maven-plugin</artifactId>
        <version>1.1</version>
        <configuration>
          <docTitle>Tiles Definition File</docTitle>
        </configuration>
      </plugin>
    </plugins>
  </reporting>


  <dependencies>
    <dependency>
      <groupId>org.apache.tiles</groupId>
      <artifactId>tiles-api</artifactId>
    </dependency>

    <dependency>
      <groupId>commons-digester</groupId>
      <artifactId>commons-digester</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.easymock</groupId>
      <artifactId>easymock</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.easymock</groupId>
      <artifactId>easymockclassextension</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.shale</groupId>
      <artifactId>shale-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

</project>

2 个答案:

答案 0 :(得分:1)

执行者插件引用包含在tiles-master pom中,它是tiles-parent pom的父pom并从那里派生。

如果您需要在项目中永久禁用此规则,请添加以下内容:

<build>
   <plugins>
      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>enforce-java</id>
            <phase>none</phase>
          </execution>
        </executions>
      </plugin>
   </plugins>
</build>

这会将id enforce-java的enforcer插件执行委托给从未执行过的none阶段。在不同的ID下添加另一个执行允许您在需要时添加自己的实施规则。

答案 1 :(得分:0)

简要介绍一下这些文档会带来以下内容:

mvn -Denforcer.skip=true ...

应该这样做。