当前位置: 首页 > 知识库问答 >
问题:

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

董嘉祯
2023-03-14

我试图编译apache瓦片,模块ties-core,但我有以下错误:

---maven enforcer插件:1.2:enforce(enforce java)@tiles-core--规则0:org。阿帕奇。专家插件。执行者。RequireJavaVersion失败,消息为:检测到的JDK版本:1.8.0不在允许的范围[1.7.0-45,1.8]。

Project apache tiles由父级和模块组成。我正在尝试编译tiles core。然而,我无法找到并理解在pom文件中使用maven enforcer插件来关闭它。请解释一下这个插件在哪里使用。

父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>

瓷砖核心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个答案

岳炎彬
2023-03-14

只要看一下这些文件,就会发现以下几点:

mvn -Denforcer.skip=true ...

应该能成功。

贺景山
2023-03-14

执法者插件引用包含在ties-masterpom中,它是您的ties-父pom的父pom,并从那里派生。

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

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

这将idforce-java的执行器插件执行委托给从不执行的no阶段。在不同的id下添加另一个执行允许您在需要时添加自己的执行器规则。

 类似资料:
  • 当前情景: 父pom有一个distributionManagement部分,其中定义了两个存储库(发布和快照);请参阅以下内容: 父pom: 基于同一pom中指定的“版本”,maven会自动识别是在发布中部署工件还是在nexus中部署快照存储库。(我相信这是使用版本是否有任何“-SNAPSHOT”后缀来完成的。) 有一个子pom定义了一些部署文件目标;请参阅以下内容: 儿童pom: 问题: 正如您

  • 问题内容: 我正在使用eclipse使用ant构建耳朵文件。我正在使用oc4j,并且我想确保在构建中包含orion- application.xml。我当前正在使用但不起作用的是: 将其添加到耳朵的正确方法是什么? 问题答案: 蚂蚁EAR任务 应通过嵌套文件集指定应放入文件夹的所有内容:

  • 项目中经常会生成一些Git系统不需要追踪(track)的文件。典型的是在编译生成过程中 产生的文件或是编程器生成的临时备份文件。当然,你不追踪(track)这些文件,可以 平时不用"git add"去把它们加到索引中。 但是这样会很快变成一件烦人的事,你发现 项目中到处有未追踪(untracked)的文件; 这样也使"git add ." 和"git commit -a" 变得实际上没有用处,同时

  • 如何在maven pom文件中定义源文件夹顺序?我目前使用的是标准的maven目录布局,但每当我运行命令“mvn eclipse:eclipse”时,源文件夹顺序如下: src/test/java src/test/Resources src/main/java src/main/Resources 如何将其设置为: src/main/java src/main/resources src/tes

  • 我所在的团队使用maven和gradle,我有一个gradle项目,希望生成一个功能正常的pom文件,以便我们的maven用户可以继续使用maven。 我已经解决了这个问题,生成了一个具有适当依赖关系的pom,如下所示: 建筑格拉德尔节选: 这对于仅创建pom上的依赖项非常有效,但gradle的maven插件API似乎不支持定义

  • 问题内容: 我正在创建一个页面,供用户上传文件。如果文件类型是其他jpg,gif和pdf,我希望使用if语句创建$ error变量。 这是我的代码: 我在构造if语句时遇到困难。我怎么说呢 问题答案: 将允许的类型放入数组并使用。