Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions EmptyProject/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,43 @@
<artifactId>EmptyProject</artifactId>
<version>1.0-SNAPSHOT</version>

<name>EmptyProject</name>
<description>A project to test the MavenPlugin</description>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<developers>
<developer>
<id>Flawden</id>
<name>Flawden</name>
<email>topchiidv1998@gmail.com</email>
<roles>
<role>Developer</role>
</roles>
</developer>
</developers>

<build>
<plugins>
<plugin>
<groupId>org.plugin</groupId>
<artifactId>MavenPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<id>print-developers</id>
<phase>compile</phase>
<goals>
<goal>print-developers</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
52 changes: 50 additions & 2 deletions MavenPlugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,59 @@
<groupId>org.plugin</groupId>
<artifactId>MavenPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>MavenPlugin</name>
<description>A Maven plugin to print developer information</description>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.9.6</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.9.6</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.9.6</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.13.1</version>
<configuration>
<goalPrefix>devinfo</goalPrefix>
</configuration>
<executions>
<execution>
<id>default</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
40 changes: 40 additions & 0 deletions MavenPlugin/src/main/java/org/plugin/AuthorsNameShower.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.plugin;

import org.apache.maven.model.Developer;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import java.util.List;

/**
* Плагин для вывода информации о разработчиках из pom.xml.
*/
@Mojo(name = "print-developers", defaultPhase = LifecyclePhase.COMPILE)
public class AuthorsNameShower extends AbstractMojo {

@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;

@Override
public void execute() throws MojoExecutionException {
getLog().info("=== Информация о разработчиках ===");

List<Developer> developers = project.getDevelopers();
if (developers == null || developers.isEmpty()) {
getLog().info("Разработчики не указаны в pom.xml");
return;
}

for (org.apache.maven.model.Developer developer : developers) {
getLog().info("ID: " + (developer.getId() != null ? developer.getId() : "Не указан"));
getLog().info("Имя: " + (developer.getName() != null ? developer.getName() : "Не указано"));
getLog().info("Email: " + (developer.getEmail() != null ? developer.getEmail() : "Не указан"));
getLog().info("Роли: " + (developer.getRoles() != null && !developer.getRoles().isEmpty() ? developer.getRoles() : "Не указаны"));
getLog().info("-------------------");
}
}
}
7 changes: 0 additions & 7 deletions MavenPlugin/src/main/java/org/plugin/Main.java

This file was deleted.

16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Практическое задание 1 # Maven plugin
# MavenPlugin

Нужно реализовать maven plugin, который будет выводить информцию о разработчике\разработчиках. Информация об этом находится в теге <developers> https://maven.apache.org/pom.html#Developers.
Maven-плагин для вывода информации о разработчиках из тега `<developers>` в `pom.xml`.

Проект MavenPlugin должен содержать сам плагин. После реализации плагина, его нужно поключить к проекту EmptyProject.

**Как выполнить:**
1. Сделать форк этого проекта
2. Сделать ветку dev в своем проекте. Выполнять работу в ней
3. После выполнения работы открыть Pull Request в master
4. Назначить ментора ревьювером
5. Отправить ссылку на PR в тг чат ментору
## Как работает
- Извлекает данные о разработчиках (ID, имя, email, роли) из `pom.xml`.
- Выводит информацию в консоль на фазе `compile`.
- Проект `EmptyProject` демонстрирует использование плагина.