maven enforcer plugin что это

Maven enforcer plugin что это

The Enforcer plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family along with many more built-in rules and user created rules.

Goals Overview

The Enforcer plugin has two goals:

Usage

General instructions on how to use the Enforcer Plugin can be found on the usage page.

In case you still have questions regarding the plugin’s usage, please have a look at the FAQ and feel free to contact the user mailing list. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the mail archive.

If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our issue tracker. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our source repository and will find supplementary information in the guide to helping with Maven.

Copyright ©2007–2021 The Apache Software Foundation. All rights reserved.

Источник

использование плагина Maven enforcer

Я хотел бы использовать плагин Maven enforcer, чтобы проверить, есть ли у меня дубликаты классов на моем пути. Я пробовал пример из здесь.

но когда я запускаю его так:

не удалось выполнить цель орг.апаш.знаток.Плагины:maven-enforcer-плагин: 1.0.1: enforce (по умолчанию-cli) в project datapopulator: параметры «правила» для цель орг.апаш.знаток.Плагины:maven-enforcer-plugin:1.0.1:принудительное исполнение отсутствует или недействителен

есть ли способ использовать это правильно?

правка #1

Если меняю конфиг такой:

производит ту же ошибку.

4 ответов

причина, по которой ваша первая версия не работала, заключается в том, что существует разница между конфигурацией плагина внутри тега выполнения и конфигурацией плагина вне тега выполнения. Выполнение используется только тогда, когда ваш плагин запускается специальной фазой полной сборки Maven.

конфигурации внутри тега отличаются от тех, что снаружи их нельзя использовать из прямого вызова командной строки. Вместо этого они применяются только тогда, когда вызывается фаза жизненного цикла, к которой они привязаны. Кроме того, если вы переместите раздел конфигурации за пределы раздела executions, он будет применяться глобально ко всем вызовам плагина.

попробуйте это, перемещая конфигурацию за пределы выполнения, поэтому она не привязана к фазе жизненного цикла.

Читайте также:  какой круг нужен для полировки фар

вы можете использовать специальный идентификатор выполнения командной строки по умолчанию, default-cli для его вызова (см. Maven Docs), см. мой пример ниже. Это работает по крайней мере с 3.1.1, и в приведенной статье говорится, что он должен работать с 2.2.0+

Если вы используете выше Maven 3.1.1 (я могу подтвердить, что он работает в 3.3.3 с enforcer v 1.4.1) вы можете указать идентификатор выполнения, который хотите использовать новый синтаксис @ (см. Maven JIRA и ответы выше);

например, для примера ниже используйте

вот фрагмент из моего пом;

Я не знаю, почему он не будет работать с конфигурацией, находящейся в исполнении, но это сработало для меня:

Источник

Maven enforcer plugin что это

The Enforcer plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family along with many more built-in rules and user created rules.

More information can be found on Apache Maven Enforcer Plugin Homepage. Question related to the usage of the Maven Enforcer Plugin should be posted on the Maven User List.

Where can I get the latest release?

You can download release source from our download page.

You can get the Maven Enforcer plugin via the following coordinates from central:

We accept Pull Requests via GitHub. The developer mailing list is the main channel of communication for contributors.
There are some guidelines which will make applying PRs easier for us:

If you plan to contribute on a regular basis, please consider filing a contributor license agreement. You can learn more about contributing via GitHub in our contribution guidelines.

This code is under the Apache Licence v2

See the NOTICE file for required notices and attributions.

You like Apache Maven? Then donate back to the ASF to support the development.

Источник

My Thoughts

Technology for the Masses

Maven Enforcer Plugin

Overview
Maven is build automation tool primarily used for java projects. Maven helps in build, documentation, dependency management, distribution etc., Maven has multiple plug-ins out of which enforcer plug-in is one where certain rules can be enforced which can cause the build to fail if those rules are not met. The enforcer plug-in helps in having standardized and reproducible build across different project environments. This plugin is termed as “Maven Enforcer Plugin – The Loving Iron Fist of Maven”

My Use cases:
We are working on restructuring on our project setup to make it more standardized and reproducible. During this process we have two typical issues:

Читайте также:  какой краской красить профильную трубу забора

Maven Enforcer Plugin
Maven Enforcer provides rules to enforce banned dependencies and dependency convergence. It also provides additional standard rules from perspective of Maven, Java versions and others, detailed rules can be found here.

Dependecy Convergence
This rule ensures that dependency version numbers converge. If a project has two dependencies A and B which are dependent on C, if the version of C that A is dependent is different than the version B is dependent then this rule will make the build fail.

Banned Dependencies
Some of the projects will have restriction not to depend on internal projects to ensure those are mutually exclusive during run time. There can also be restriction not to depend on snapshot versions and specific releases. These kind of restrictions can be implemented via enforcer plugin rules

Implementing Banned dependencies and Dependency Convergence

The below code snippet provides the following features:

Disable Maven Enforcer Rules On Specific Child Projects
The enforcer rules implemented on parent will be applied on the child projects. In case of scenario where specific child project need to be exempted from enforcer rules, enforcer-plugin need to be overridden mapping to none of the life cycle phases. Find below the code snippet

Источник

Apache Maven Enforcer Plugin Example

Posted by: Firouzeh hejazi in Maven June 18th, 2019 0 Views

1. Apache Maven Enforcer Plugin – Introduction

Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information.

1.1 Maven installation guide

You just need to download the Maven’s zip file, unzip it to a folder, and configure the Windows environment variables.

1.2 JDK and JAVA_HOME

Make sure JDK is installed, and JAVA_HOME environment variable is configured. Follow the steps below to see Environment Variables:

1.3 Download Apache Maven

That’s all, just download and unzip, installation is NOT required.

1.4 Add MAVEN_HOME system variable

Add a MAVEN_HOME system variables, and point it to the Maven folder.

Here are the steps to add a new variable:

Click New to add a new variable:

Pay attention to the capital letters of the variable name, as it is case sensitive.

Variable value points to the location we extracted the Maven zip file.

1.5 Add %MAVEN_HOME%\bin To PATH

In system variables, find PATH variable and follow the steps below:

Читайте также:  цвн диагноз что это такое

Click Edit:

Add %MAVEN_HOME%\bin to the end of the Variable value:

1.6 Verification

Done, start a new command prompt, type mvn –version : Holddown the Windows Key and Press R on your keyboard.

By clicking OK, cmd.exe runs. Now type the command below:

2. What is Maven Enforcer Plugin?

The Enforcer plugin helps maintain project standards and provides goals to control certain environmental constraints such as Maven version, JDK version and OS family along with many more standard(built-in) rules and user created rules.

General instructions on how to use the Enforcer Plugin can be found on the usage page.

3. What can the Enforcer plugin do for the project?

Now lets see how to use this plugin using an example:

4. Plugin Configuration and Goals

5. Create a Maven project

Open IntelliJ Idea, choose Create New Project:

From the right sidebar select Maven:

In the next window enter GroupId and ArtifactId as you wish:

By clicking Next the Project name and location is displayed. You can change the values as you wish.

After clicking the “Finish” button this window appears in the IDE:

Let’s define the enforce goal in the executions tag. Furthermore, we’ll add the configuration tag that holds the rules definitions for the project: executions tag:

The keyword enforce shows there are rules to follow. In fact the rules are enforced during the build phase of the project.

All rules also accept a message parameter for specifying a custom message: rules:

To check the rule’s behavior, we run mvn clean compile in the Terminal window:

It’ll produce the following error lines on the console:

As you see we have warnings on Rule 1 and Rule 2 with our defined messages.

Now we add another rule related to OS version:

Require OS Version: This rule can enforce certain values about the Operating System and processor architecture. The values and code used to determine if an OS is allowed are exactly the same as the OS Profile activation in Maven. rules:

To check the rule’s behavior, we run again mvn clean compile in the Terminal window. We can run first mvn clean then mvn compile

Now we run the install command:

As you see there is one rule added to WARNINGs saying that windows 7 is not allowed.

6. Download the Complete Source Code

This was a tutorial of Apache Maven Enforcer Plugin Example.

Источник

Сказочный портал