简体   繁体   English

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

[英]Find out how maven-enforcer-plugin is used in certain pom files

I am trying to compile apache tiles, module tiles-core but I have the following error: 我正在尝试编译apache tile,tiles-core模块,但是出现以下错误:

--- maven-enforcer-plugin:1.2:enforce (enforce-java) @ tiles-core --- Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message: Detected JDK Version: 1.8.0 is not in the allowed range [1.7.0-45,1.8). --- maven-enforcer-plugin:1.2:enforce(enforce-java)@ tiles-core ---规则0:org.apache.maven.plugins.enforcer.RequireJavaVersion失败并显示以下消息:检测到的JDK版本为1.8.0不在允许的范围内[1.7.0-45,1.8)。

Project apache tiles consists of parent and modules. 项目apache磁贴包含父级和模块。 I'm trying to compile tiles-core. 我正在尝试编译tile-core。 However I cant find and understand where maven-enforcer-plugin is used in pom files to switch it off. 但是我找不到并了解在pom文件中将maven-enforcer-plugin用来关闭它的地方。 Please, explain where this plugin is used. 请解释该插件的使用位置。

Parent pom file 父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 core pom file 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>

The enforcer plugin reference is contained in the tiles-master pom which is the parent pom of your tiles-parent pom and derived from there. 强制性插件参考包含在tiles-master pom中, tiles-master pom是tiles-parent pom tiles-parent pom,并从此处派生。

If you need to disable this rule permanently in your project adding the following should do the trick: 如果您需要在项目中永久禁用此规则,请添加以下内容:

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

This delegates the enforcer plugin execution for id enforce-java to the none phase which is never executed. 这会将id enforce-java程序插件执行委派给从不执行的none阶段。 Adding another execution under a different id allows you to add your own enforcer rule if required. 如果需要,可以使用其他ID添加另一个执行,从而可以添加自己的执行器规则。

Just a short look into the docs would have brought up the following: 只需简短浏览一下文档,就会得出以下内容:

mvn -Denforcer.skip=true ...

should do the trick. 应该可以。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法执行Maven-Enforcer-Plug - Failed to execute maven-enforcer-plugin maven-enforcer-plugin 误报 RequireJavaVersion - maven-enforcer-plugin False Positive RequireJavaVersion Maven 插件问题:maven-enforcer-plugin:3.0.0-M3:enforce 有些 Enforcer 规则失败 - Problem with Maven plugin :maven-enforcer-plugin:3.0.0-M3:enforce Some Enforcer rules have failed 无法执行目标 org.apache.maven.plugins:maven-enforcer-plugin - Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin 版本:display-plugin-updates不了解maven-enforcer-plugin - versions:display-plugin-updates does not understand maven-enforcer-plugin 在Eclipse中创建org.jenkins-ci.plugins时出现maven-enforcer-plugin问题 - maven-enforcer-plugin issue while creating org.jenkins-ci.plugins in eclipse 如何使用 Maven Enforcer 插件? - How to use of the Maven Enforcer plugin? 当maven 3.2.5在travis-ci.org上与3.1.1一起运行时,为什么会检测到maven 3.2.5? - Why does maven-enforcer-plugin detect maven 3.2.5 when it's run with 3.1.1 on travis-ci.org? 无法执行 org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce: org/codehaus/plexus/util/StringUtils - Fail to execute org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce: org/codehaus/plexus/util/StringUtils 执行maven 3 - 何时使用maven enforcer插件?什么时候使用pom先决条件元素? - enforcing maven 3 - when to use maven enforcer plugin? when to use pom prerequisites element?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM