-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First part was to "reverse" MavenCli into CLIng, that also became a huge and complex beast. Now, sanitization comes, tearing down unneeded stuff. CLIng should be simple and straightforward. Now the **invoker** fully parses args, creates Maven instance (ie. local, using Maven components on classpath) and invokes Maven. The new **executor** in turn does NOT fully parses args and is logical equivalent of maven-invoker. Changes: * radically simplify CLIng existing classes (and especially API - the fact we have "local", "resident" etc invoker is actually implementation detail). * introduce "executor", a "lower level" tool that does not parse args (and is logical equivalent of maven-invoker) and support Maven 4.x and Maven 3.x. --- https://issues.apache.org/jira/browse/MNG-8375
- Loading branch information
Showing
67 changed files
with
1,580 additions
and
1,365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-Daether.transport.jdk.httpVersion=HTTP_1_1 |
55 changes: 55 additions & 0 deletions
55
api/maven-api-cli/src/main/java/org/apache/maven/api/cli/Executor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.maven.api.cli; | ||
|
||
import org.apache.maven.api.annotations.Experimental; | ||
import org.apache.maven.api.annotations.Nonnull; | ||
|
||
/** | ||
* Defines the contract for a component responsible for executing a Maven tool | ||
* using the information provided in an {@link ExecutorRequest}. This interface is central | ||
* to the execution of Maven commands and builds, but it does not construct nor fully parses arguments. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
@Experimental | ||
public interface Executor extends AutoCloseable { | ||
/** | ||
* Invokes the tool application using the provided {@link ExecutorRequest}. | ||
* This method is responsible for executing the command or build | ||
* process based on the information contained in the request. | ||
* | ||
* @param executorRequest the request containing all necessary information for the execution | ||
* @return an integer representing the exit code of the execution (0 typically indicates success) | ||
* @throws ExecutorException if an error occurs during the execution process | ||
*/ | ||
int execute(@Nonnull ExecutorRequest executorRequest) throws ExecutorException; | ||
|
||
/** | ||
* Closes and disposes of this {@link Executor} instance, releasing any resources it may hold. | ||
* This method is called automatically when using try-with-resources statements. | ||
* | ||
* <p>The default implementation does nothing. Subclasses should override this method | ||
* if they need to perform cleanup operations.</p> | ||
* | ||
* @throws ExecutorException if an error occurs while closing the {@link Executor} | ||
*/ | ||
@Override | ||
default void close() throws ExecutorException {} | ||
} |
52 changes: 52 additions & 0 deletions
52
api/maven-api-cli/src/main/java/org/apache/maven/api/cli/ExecutorException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.maven.api.cli; | ||
|
||
import org.apache.maven.api.annotations.Experimental; | ||
import org.apache.maven.api.annotations.Nullable; | ||
import org.apache.maven.api.services.MavenException; | ||
|
||
/** | ||
* Represents an exception that occurs during the execution of a Maven build or command. | ||
* This exception is typically thrown when there are errors during the execution of a Maven | ||
* process, such as wrong cwd, non-existent installation directory, or other runtime issues. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
@Experimental | ||
public class ExecutorException extends MavenException { | ||
/** | ||
* Constructs a new {@code InvokerException} with the specified detail message. | ||
* | ||
* @param message the detail message explaining the cause of the exception | ||
*/ | ||
public ExecutorException(@Nullable String message) { | ||
super(message); | ||
} | ||
|
||
/** | ||
* Constructs a new {@code InvokerException} with the specified detail message and cause. | ||
* | ||
* @param message the detail message explaining the cause of the exception | ||
* @param cause the underlying cause of the exception | ||
*/ | ||
public ExecutorException(@Nullable String message, @Nullable Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
api/maven-api-cli/src/main/java/org/apache/maven/api/cli/ExecutorRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.maven.api.cli; | ||
|
||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.apache.maven.api.annotations.Experimental; | ||
import org.apache.maven.api.annotations.Immutable; | ||
import org.apache.maven.api.annotations.Nonnull; | ||
|
||
/** | ||
* Represents a request to execute Maven with command-line arguments. | ||
* This interface encapsulates all the necessary information needed to execute | ||
* Maven command with arguments. The arguments were not parsed, they are just passed over | ||
* to executed tool. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
@Immutable | ||
@Experimental | ||
public interface ExecutorRequest { | ||
/** | ||
* The parser request this instance was created from. | ||
*/ | ||
@Nonnull | ||
ParserRequest parserRequest(); | ||
|
||
/** | ||
* Returns the current working directory for the Maven execution. | ||
* This is typically the directory from which Maven was invoked. | ||
* | ||
* @return the current working directory path | ||
*/ | ||
@Nonnull | ||
Path cwd(); | ||
|
||
/** | ||
* Returns the Maven installation directory. | ||
* This is usually set by the Maven launcher script using the "maven.home" system property. | ||
* | ||
* @return the Maven installation directory path | ||
*/ | ||
@Nonnull | ||
Path installationDirectory(); | ||
|
||
/** | ||
* Returns the user's home directory. | ||
* This is typically obtained from the "user.home" system property. | ||
* | ||
* @return the user's home directory path | ||
*/ | ||
@Nonnull | ||
Path userHomeDirectory(); | ||
|
||
/** | ||
* Returns the list of extra JVM arguments to be passed to the forked process. | ||
* These arguments allow for customization of the JVM environment in which tool will run. | ||
* This property is used ONLY by executors and invokers that spawn a new JVM. | ||
* | ||
* @return an Optional containing the list of extra JVM arguments, or empty if not specified | ||
*/ | ||
@Nonnull | ||
Optional<List<String>> jvmArguments(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.