Skip to content

Commit 721a314

Browse files
committed
CLIng
1 parent 75e3c05 commit 721a314

File tree

86 files changed

+7555
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+7555
-123
lines changed

apache-maven/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ under the License.
3737
</properties>
3838

3939
<dependencies>
40+
<dependency>
41+
<groupId>org.apache.maven</groupId>
42+
<artifactId>maven-cli</artifactId>
43+
</dependency>
4044
<dependency>
4145
<groupId>org.apache.maven</groupId>
4246
<artifactId>maven-embedder</artifactId>

apache-maven/src/assembly/component.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ under the License.
8383
<outputDirectory>bin</outputDirectory>
8484
<includes>
8585
<include>mvn</include>
86+
<include>mvnenc</include>
8687
<include>mvnDebug</include>
8788
<!-- This is so that CI systems can periodically run the profiler -->
8889
<include>mvnyjp</include>

apache-maven/src/assembly/maven/bin/m2.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
#
19-
main is org.apache.maven.cli.MavenCli from plexus.core
18+
19+
main is ${maven.mainClass} from plexus.core
2020

2121
set maven.conf default ${maven.home}/conf
2222
set maven.installation.conf default ${maven.conf}

apache-maven/src/assembly/maven/bin/mvn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ MAVEN_PROJECTBASEDIR="`find_maven_basedir "$@"`"
167167
MAVEN_OPTS="$MAVEN_OPTS `concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config"`"
168168
LAUNCHER_JAR=`echo "$MAVEN_HOME"/boot/plexus-classworlds-*.jar`
169169
LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
170+
MAVEN_MAIN_CLASS=${MAVEN_MAIN_CLASS:=org.apache.maven.cling.MavenCling}
170171

171172
# For Cygwin and MinGW, switch paths to Windows format before running java(1) command
172173
if $cygwin || $mingw ; then
@@ -185,6 +186,7 @@ exec "$JAVACMD" \
185186
-classpath "$LAUNCHER_JAR" \
186187
"-Dclassworlds.conf=$CLASSWORLDS_CONF" \
187188
"-Dmaven.home=$MAVEN_HOME" \
189+
"-Dmaven.mainClass=$MAVEN_MAIN_CLASS" \
188190
"-Dlibrary.jansi.path=${MAVEN_HOME}/lib/jansi-native" \
189191
"-Dmaven.multiModuleProjectDirectory=$MAVEN_PROJECTBASEDIR" \
190192
$LAUNCHER_CLASS \

apache-maven/src/assembly/maven/bin/mvn.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s
173173

174174
for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set LAUNCHER_JAR="%%i"
175175
set LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
176+
if "%MAVEN_MAIN_CLASS%"=="" @set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling
176177

177178
"%JAVACMD%" ^
178179
%MAVEN_OPTS% ^
@@ -181,6 +182,7 @@ set LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
181182
-classpath %LAUNCHER_JAR% ^
182183
"-Dclassworlds.conf=%CLASSWORLDS_CONF%" ^
183184
"-Dmaven.home=%MAVEN_HOME%" ^
185+
"-Dmaven.mainClass=%MAVEN_MAIN_CLASS%" ^
184186
"-Dlibrary.jansi.path=%MAVEN_HOME%\lib\jansi-native" ^
185187
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
186188
%LAUNCHER_CLASS% ^
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
# -----------------------------------------------------------------------------
21+
# Apache Maven Encrypt Script
22+
#
23+
# Environment Variable Prerequisites
24+
#
25+
# JAVA_HOME (Optional) Points to a Java installation.
26+
# MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
27+
# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
28+
# -----------------------------------------------------------------------------
29+
30+
env MAVEN_MAIN_CLASS="org.apache.maven.cling.MavenEncCling" "`dirname "$0"`/mvn" "$@"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@REM Licensed to the Apache Software Foundation (ASF) under one
2+
@REM or more contributor license agreements. See the NOTICE file
3+
@REM distributed with this work for additional information
4+
@REM regarding copyright ownership. The ASF licenses this file
5+
@REM to you under the Apache License, Version 2.0 (the
6+
@REM "License"); you may not use this file except in compliance
7+
@REM with the License. You may obtain a copy of the License at
8+
@REM
9+
@REM http://www.apache.org/licenses/LICENSE-2.0
10+
@REM
11+
@REM Unless required by applicable law or agreed to in writing,
12+
@REM software distributed under the License is distributed on an
13+
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
@REM KIND, either express or implied. See the License for the
15+
@REM specific language governing permissions and limitations
16+
@REM under the License.
17+
18+
@REM -----------------------------------------------------------------------------
19+
@REM Apache Maven Encrypt Script
20+
@REM
21+
@REM Environment Variable Prerequisites
22+
@REM
23+
@REM JAVA_HOME (Optional) Points to a Java installation.
24+
@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands.
25+
@REM MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending.
26+
@REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
27+
@REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
28+
@REM -----------------------------------------------------------------------------
29+
30+
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
31+
@echo off
32+
@REM set title of command window
33+
title %0
34+
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
35+
@if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO%
36+
37+
@setlocal
38+
39+
@set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenEncCling
40+
41+
@call "%~dp0"mvn.cmd %*

api/maven-api-cli/pom.xml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<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/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<parent>
24+
<groupId>org.apache.maven</groupId>
25+
<artifactId>maven-api</artifactId>
26+
<version>4.0.0-beta-5-SNAPSHOT</version>
27+
</parent>
28+
29+
<artifactId>maven-api-cli</artifactId>
30+
<name>Maven 4 API :: CLI</name>
31+
<description>Maven 4 API - CLI.</description>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.apache.maven</groupId>
36+
<artifactId>maven-api-meta</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.apache.maven</groupId>
40+
<artifactId>maven-api-core</artifactId>
41+
</dependency>
42+
</dependencies>
43+
44+
<build>
45+
<plugins>
46+
<plugin>
47+
<groupId>org.codehaus.modello</groupId>
48+
<artifactId>modello-maven-plugin</artifactId>
49+
<configuration>
50+
<version>1.2.0</version>
51+
<models>
52+
<model>src/main/mdo/core-extensions.mdo</model>
53+
</models>
54+
<templates>
55+
<template>model.vm</template>
56+
</templates>
57+
<params>
58+
<param>packageModelV4=org.apache.maven.api.cli.extensions</param>
59+
<param>packageToolV4=org.apache.maven.cli.internal.extension.io</param>
60+
</params>
61+
<velocityBasedir>${project.basedir}/../../src/mdo</velocityBasedir>
62+
</configuration>
63+
<executions>
64+
<execution>
65+
<id>modello</id>
66+
<goals>
67+
<goal>velocity</goal>
68+
<goal>xsd</goal>
69+
</goals>
70+
</execution>
71+
</executions>
72+
</plugin>
73+
</plugins>
74+
</build>
75+
</project>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.api.cli;
20+
21+
import org.apache.maven.api.annotations.Experimental;
22+
import org.apache.maven.api.annotations.Nonnull;
23+
24+
/**
25+
* Defines the contract for a component responsible for invoking a Maven application
26+
* using the information provided in an {@link InvokerRequest}. This interface is central
27+
* to the execution of Maven commands and builds.
28+
*
29+
* <p>The Invoker is designed to be flexible, allowing for different implementations
30+
* that can handle various types of {@link InvokerRequest InvokerRequests}. It also implements
31+
* {@link AutoCloseable} to ensure proper resource management.</p>
32+
*
33+
* @param <R> The specific type of {@link InvokerRequest} this {@code Invoker} can handle, extending {@link InvokerRequest}
34+
*
35+
* @since 4.0.0
36+
*/
37+
@Experimental
38+
public interface Invoker<R extends InvokerRequest<? extends Options>> extends AutoCloseable {
39+
/**
40+
* Invokes the Maven application using the provided {@link InvokerRequest}.
41+
* This method is responsible for executing the Maven command or build
42+
* process based on the information contained in the request.
43+
*
44+
* @param invokerRequest the request containing all necessary information for the invocation
45+
* @return an integer representing the exit code of the invocation (0 typically indicates success)
46+
* @throws InvokerException if an error occurs during the invocation process
47+
*/
48+
int invoke(@Nonnull R invokerRequest) throws InvokerException;
49+
50+
/**
51+
* Closes and disposes of this {@link Invoker} instance, releasing any resources it may hold.
52+
* This method is called automatically when using try-with-resources statements.
53+
*
54+
* <p>The default implementation does nothing. Subclasses should override this method
55+
* if they need to perform cleanup operations.</p>
56+
*
57+
* @throws InvokerException if an error occurs while closing the {@link Invoker}
58+
*/
59+
@Override
60+
default void close() throws InvokerException {}
61+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.api.cli;
20+
21+
import org.apache.maven.api.annotations.Experimental;
22+
import org.apache.maven.api.annotations.Nullable;
23+
import org.apache.maven.api.services.MavenException;
24+
25+
/**
26+
* Represents an exception that occurs during the invocation of a Maven build or command.
27+
* This exception is typically thrown when there are errors during the execution of a Maven
28+
* process, such as build failures, plugin errors, or other runtime issues.
29+
*
30+
* @since 4.0.0
31+
*/
32+
@Experimental
33+
public class InvokerException extends MavenException {
34+
/**
35+
* Constructs a new {@code InvokerException} with the specified detail message.
36+
*
37+
* @param message the detail message explaining the cause of the exception
38+
*/
39+
public InvokerException(@Nullable String message) {
40+
super(message);
41+
}
42+
43+
/**
44+
* Constructs a new {@code InvokerException} with the specified detail message and cause.
45+
*
46+
* @param message the detail message explaining the cause of the exception
47+
* @param cause the underlying cause of the exception
48+
*/
49+
public InvokerException(@Nullable String message, @Nullable Throwable cause) {
50+
super(message, cause);
51+
}
52+
}

0 commit comments

Comments
 (0)