-
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.
Maven shell Changes: * (unrelated) contains fix for property handling in embedded executor and in lookup invoker * pulled `-o` (offline) option to "generic" Options from MavenOptions * introduce mvnsh (scripts, options, CLIng main class) * simplified invokers (only one context needed for maven now) * invokers made "reentrant", it all depends HOW context is created Related PRs: * mvnd changes apache/maven-mvnd#1228 --- https://issues.apache.org/jira/browse/MNG-8437
- Loading branch information
Showing
44 changed files
with
1,295 additions
and
663 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
# 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. | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Apache Maven Encrypt Script | ||
# | ||
# Environment Variable Prerequisites | ||
# | ||
# JAVA_HOME (Optional) Points to a Java installation. | ||
# MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. | ||
# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. | ||
# ----------------------------------------------------------------------------- | ||
|
||
"`dirname "$0"`/mvn" --shell "$@" |
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,39 @@ | ||
@REM Licensed to the Apache Software Foundation (ASF) under one | ||
@REM or more contributor license agreements. See the NOTICE file | ||
@REM distributed with this work for additional information | ||
@REM regarding copyright ownership. The ASF licenses this file | ||
@REM to you under the Apache License, Version 2.0 (the | ||
@REM "License"); you may not use this file except in compliance | ||
@REM with the License. You may obtain a copy of the License at | ||
@REM | ||
@REM http://www.apache.org/licenses/LICENSE-2.0 | ||
@REM | ||
@REM Unless required by applicable law or agreed to in writing, | ||
@REM software distributed under the License is distributed on an | ||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
@REM KIND, either express or implied. See the License for the | ||
@REM specific language governing permissions and limitations | ||
@REM under the License. | ||
|
||
@REM ----------------------------------------------------------------------------- | ||
@REM Apache Maven Encrypt Script | ||
@REM | ||
@REM Environment Variable Prerequisites | ||
@REM | ||
@REM JAVA_HOME (Optional) Points to a Java installation. | ||
@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands. | ||
@REM MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending. | ||
@REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. | ||
@REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. | ||
@REM ----------------------------------------------------------------------------- | ||
|
||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' | ||
@echo off | ||
@REM set title of command window | ||
title %0 | ||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' | ||
@if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO% | ||
|
||
@setlocal | ||
|
||
@call "%~dp0"mvn.cmd --shell %* |
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
44 changes: 44 additions & 0 deletions
44
api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvnsh/ShellOptions.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,44 @@ | ||
/* | ||
* 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.mvnsh; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
import org.apache.maven.api.annotations.Experimental; | ||
import org.apache.maven.api.annotations.Nonnull; | ||
import org.apache.maven.api.cli.Options; | ||
|
||
/** | ||
* Defines the options specific to the Maven Shell tool. | ||
* This interface extends the general {@link Options} interface, adding shell-specific configuration options. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
@Experimental | ||
public interface ShellOptions extends Options { | ||
/** | ||
* Returns a new instance of ShellOptions with values interpolated using the given properties. | ||
* | ||
* @param properties a collection of property maps to use for interpolation | ||
* @return a new EncryptOptions instance with interpolated values | ||
*/ | ||
@Nonnull | ||
ShellOptions interpolate(Collection<Map<String, String>> properties); | ||
} |
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
74 changes: 74 additions & 0 deletions
74
impl/maven-cli/src/main/java/org/apache/maven/cling/MavenShellCling.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,74 @@ | ||
/* | ||
* 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.cling; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.maven.api.cli.Invoker; | ||
import org.apache.maven.api.cli.InvokerRequest; | ||
import org.apache.maven.api.cli.ParserException; | ||
import org.apache.maven.api.cli.ParserRequest; | ||
import org.apache.maven.cling.invoker.ProtoLogger; | ||
import org.apache.maven.cling.invoker.ProtoLookup; | ||
import org.apache.maven.cling.invoker.mvnsh.ShellInvoker; | ||
import org.apache.maven.cling.invoker.mvnsh.ShellParser; | ||
import org.apache.maven.jline.JLineMessageBuilderFactory; | ||
import org.codehaus.plexus.classworlds.ClassWorld; | ||
|
||
/** | ||
* Maven shell. | ||
*/ | ||
public class MavenShellCling extends ClingSupport { | ||
/** | ||
* "Normal" Java entry point. Note: Maven uses ClassWorld Launcher and this entry point is NOT used under normal | ||
* circumstances. | ||
*/ | ||
public static void main(String[] args) throws IOException { | ||
int exitCode = new MavenShellCling().run(args); | ||
System.exit(exitCode); | ||
} | ||
|
||
/** | ||
* ClassWorld Launcher "enhanced" entry point: returning exitCode and accepts Class World. | ||
*/ | ||
public static int main(String[] args, ClassWorld world) throws IOException { | ||
return new MavenShellCling(world).run(args); | ||
} | ||
|
||
public MavenShellCling() { | ||
super(); | ||
} | ||
|
||
public MavenShellCling(ClassWorld classWorld) { | ||
super(classWorld); | ||
} | ||
|
||
@Override | ||
protected Invoker createInvoker() { | ||
return new ShellInvoker( | ||
ProtoLookup.builder().addMapping(ClassWorld.class, classWorld).build()); | ||
} | ||
|
||
@Override | ||
protected InvokerRequest parseArguments(String[] args) throws ParserException, IOException { | ||
return new ShellParser() | ||
.parseInvocation(ParserRequest.mvnsh(args, new ProtoLogger(), new JLineMessageBuilderFactory()) | ||
.build()); | ||
} | ||
} |
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.