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
23 changes: 23 additions & 0 deletions EmptyProject/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,34 @@
<groupId>org.example</groupId>
<artifactId>EmptyProject</artifactId>
<version>1.0-SNAPSHOT</version>
<developers>
<developer>
<id>1</id>
<name>someName</name>
<email>some@Email.com</email>
</developer>
</developers>

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

<build>
<plugins>
<plugin>
<groupId>org.plugin</groupId>
<artifactId>MavenPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>greet</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
36 changes: 36 additions & 0 deletions MavenPlugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,47 @@
<groupId>org.plugin</groupId>
<artifactId>MavenPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-plugin.version>3.15.1</maven-plugin.version>
<maven-plugin-api.version>3.9.9</maven-plugin-api.version>
<maven-project.version>2.2.1</maven-project.version>
<goalPrefix>greet</goalPrefix>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven-plugin-api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>${maven-plugin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>${maven-project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>${maven-plugin.version}</version>
<configuration>
<goalPrefix>${goalPrefix}</goalPrefix>
</configuration>
</plugin>
</plugins>
</build>
</project>
7 changes: 0 additions & 7 deletions MavenPlugin/src/main/java/org/plugin/Main.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.plugin.mojo;

import org.apache.maven.model.Contributor;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
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;

@Mojo(name = "greet", defaultPhase = LifecyclePhase.CLEAN)
public class GreetingsDevelopersMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;

/**
* Можно красиво разбирать объект {@link Contributor}
* при желании...
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Project ArtifactId: " + project.getArtifactId());
getLog().info("Project Version: " + project.getVersion());
getLog().info("Project Packaging: " + project.getPackaging());

getLog().info("Developers:");

project.getDevelopers().forEach(developer ->
getLog().info(developer.toString())
);
/*
List<Contributor> developers = project.getDevelopers();
developers.forEach(dev -> getLog().info(
dev.getName()
+ dev.getEmail()
+ dev.getOrganization()
));
*/
}
}