Skip to content

Commit

Permalink
[MNG-8410] API cleanup
Browse files Browse the repository at this point in the history
* Move plugin api to maven-api-plugin
* Rename maven-api-meta to maven-api-annotations
  • Loading branch information
gnodet committed Dec 8, 2024
1 parent 8d4f455 commit 9de37db
Show file tree
Hide file tree
Showing 51 changed files with 93 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<version>4.0.0-rc-2-SNAPSHOT</version>
</parent>

<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
<name>Maven 4 API :: Meta annotations</name>
<description>Maven 4 API - Java meta annotations.</description>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion api/maven-api-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion api/maven-api-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
package org.apache.maven.api;

import org.apache.maven.api.annotations.Config;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.annotations.Nullable;

import java.util.Map;

/**
* Configuration constants.
Expand Down Expand Up @@ -432,5 +436,48 @@ public final class Constants {
@Config(type = "java.lang.Integer")
public static final String MAVEN_DEPLOY_SNAPSHOT_BUILD_NUMBER = "maven.deploy.snapshot.buildNumber";


/**
* Check if the given feature is active.
*/
public static boolean isEnabled(@Nullable Map<String, String> userProperties, @Nonnull String key) {
return doGet(userProperties, key, false);
}

/**
* Check if the given feature is active.
*/
public static boolean isEnabled(@Nullable Map<?, ?> userProperties, @Nonnull String key, boolean def) {
return doGet(userProperties, key, def);
}

/**
* Check if the consumer POM feature is active.
*/
public static boolean isEnabled(@Nullable Session session, @Nonnull String key) {
return isEnabled(session != null ? session.getUserProperties() : null, key);
}

/**
* Check if the consumer POM feature is active.
*/
public static boolean isEnabled(@Nullable Session session, @Nonnull String key, boolean def) {
return isEnabled(session != null ? session.getUserProperties() : null, key, def);
}

private static boolean doGet(Map<?, ?> userProperties, String key, boolean def) {
return doGet(userProperties != null ? userProperties.get(key) : null, def);
}

private static boolean doGet(Object val, boolean def) {
if (val instanceof Boolean) {
return (Boolean) val;
} else if (val != null) {
return Boolean.parseBoolean(val.toString());
} else {
return def;
}
}

private Constants() {}
}

This file was deleted.

2 changes: 1 addition & 1 deletion api/maven-api-metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion api/maven-api-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion api/maven-api-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// CHECKSTYLE_OFF: RegexpHeader
/**
* Maven Plugin Annotations.
*/
package org.apache.maven.api.plugin.annotations;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// CHECKSTYLE_OFF: RegexpHeader
/**
* Maven Plugin API.
*/
package org.apache.maven.api.plugin;
2 changes: 1 addition & 1 deletion api/maven-api-settings/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion api/maven-api-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion api/maven-api-toolchain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion api/maven-api-xml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<description>A new immutable API for Maven 4 to better manage what plugins and extensions can influence.</description>

<modules>
<module>maven-api-meta</module>
<module>maven-api-annotations</module>
<module>maven-api-di</module>
<module>maven-api-xml</module>
<module>maven-api-model</module>
Expand Down
2 changes: 1 addition & 1 deletion compat/maven-model-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion compat/maven-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion compat/maven-plugin-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion compat/maven-repository-metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion compat/maven-settings/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion compat/maven-toolchain-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.maven.api.feature.Features;
import org.apache.maven.api.Constants;
import org.apache.maven.api.model.Model;
import org.apache.maven.api.services.Lookup;
import org.apache.maven.eventspy.EventSpy;
Expand Down Expand Up @@ -415,7 +416,8 @@ private boolean isRegularFile(Artifact artifact) {
private void installIntoProjectLocalRepository(Artifact artifact) {
String extension = artifact.getExtension();
String classifier = artifact.getClassifier();
if (Features.consumerPom(session.getUserProperties())) {
Properties userProperties = session.getUserProperties();
if (Constants.isEnabled(userProperties, Constants.MAVEN_CONSUMER_POM, true)) {
if ("pom".equals(extension)) {
if (classifier == null || classifier.isEmpty()) {
classifier = "build";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import org.apache.maven.api.feature.Features;
import org.apache.maven.api.Constants;
import org.apache.maven.api.model.Model;
import org.apache.maven.api.services.ModelBuilderException;
import org.apache.maven.internal.transformation.ConsumerPomArtifactTransformer;
Expand Down Expand Up @@ -80,7 +81,8 @@ public void injectTransformedArtifacts(RepositorySystemSession session, MavenPro
// If there is no build POM there is no reason to inject artifacts for the consumer POM.
return;
}
if (Features.consumerPom(session.getUserProperties())) {
Map<String, String> userProperties = session.getUserProperties();
if (Constants.isEnabled(userProperties, Constants.MAVEN_CONSUMER_POM, true)) {
Path buildDir =
project.getBuild() != null ? Paths.get(project.getBuild().getDirectory()) : null;
if (buildDir != null) {
Expand Down Expand Up @@ -133,14 +135,16 @@ private void doDeleteFiles() {
}

public InstallRequest remapInstallArtifacts(RepositorySystemSession session, InstallRequest request) {
if (Features.consumerPom(session.getUserProperties()) && consumerPomPresent(request.getArtifacts())) {
Map<String, String> userProperties = session.getUserProperties();
if (Constants.isEnabled(userProperties, Constants.MAVEN_CONSUMER_POM, true) && consumerPomPresent(request.getArtifacts())) {
request.setArtifacts(replacePom(request.getArtifacts()));
}
return request;
}

public DeployRequest remapDeployArtifacts(RepositorySystemSession session, DeployRequest request) {
if (Features.consumerPom(session.getUserProperties()) && consumerPomPresent(request.getArtifacts())) {
Map<String, String> userProperties = session.getUserProperties();
if (Constants.isEnabled(userProperties, Constants.MAVEN_CONSUMER_POM, true) && consumerPomPresent(request.getArtifacts())) {
request.setArtifacts(replacePom(request.getArtifacts()));
}
return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ under the License.

<exportedArtifacts>
<!-- maven 4 api -->
<exportedArtifact>org.apache.maven:maven-api-annotations</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-api-core</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-api-di</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-api-meta</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-api-metadata</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-api-model</exportedArtifact>
<exportedArtifact>org.apache.maven:maven-api-plugin</exportedArtifact>
Expand Down
2 changes: 1 addition & 1 deletion impl/maven-di/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion impl/maven-executor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<artifactId>maven-api-annotations</artifactId>
<scope>provided</scope>
</dependency>

Expand Down
Loading

0 comments on commit 9de37db

Please sign in to comment.