Skip to content
Merged
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
1 change: 1 addition & 0 deletions apache-maven/src/assembly/component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ under the License.
<include>mvn</include>
<include>mvnenc</include>
<include>mvnsh</include>
<include>mvnup</include>
<include>mvnDebug</include>
<include>mvnencDebug</include>
<!-- This is so that CI systems can periodically run the profiler -->
Expand Down
3 changes: 3 additions & 0 deletions apache-maven/src/assembly/maven/bin/mvn
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ handle_args() {
--shell)
MAVEN_MAIN_CLASS="org.apache.maven.cling.MavenShellCling"
;;
--up)
MAVEN_MAIN_CLASS="org.apache.maven.cling.MavenUpCling"
;;
*)
;;
esac
Expand Down
10 changes: 6 additions & 4 deletions apache-maven/src/assembly/maven/bin/mvn.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -179,22 +179,22 @@ if not exist "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadJvmConfig
set JVM_CONFIG_MAVEN_OPTS=
for /F "usebackq tokens=* delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do (
set "line=%%a"

rem Skip empty lines and full-line comments
echo !line! | findstr /b /r /c:"[ ]*#" >nul
if errorlevel 1 (
rem Handle end-of-line comments by taking everything before #
for /f "tokens=1* delims=#" %%i in ("!line!") do set "line=%%i"

rem Trim leading/trailing spaces while preserving spaces in quotes
set "trimmed=!line!"
for /f "tokens=* delims= " %%i in ("!trimmed!") do set "trimmed=%%i"
for /l %%i in (1,1,100) do if "!trimmed:~-1!"==" " set "trimmed=!trimmed:~0,-1!"

rem Replace MAVEN_PROJECTBASEDIR placeholders
set "trimmed=!trimmed:${MAVEN_PROJECTBASEDIR}=%MAVEN_PROJECTBASEDIR%!"
set "trimmed=!trimmed:$MAVEN_PROJECTBASEDIR=%MAVEN_PROJECTBASEDIR%!"

if not "!trimmed!"=="" (
if "!JVM_CONFIG_MAVEN_OPTS!"=="" (
set "JVM_CONFIG_MAVEN_OPTS=!trimmed!"
Expand Down Expand Up @@ -229,6 +229,8 @@ if "%~1"=="--debug" (
set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenEncCling"
) else if "%~1"=="--shell" (
set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenShellCling"
) else if "%~1"=="--up" (
set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenUpCling"
)
exit /b 0

Expand Down
30 changes: 30 additions & 0 deletions apache-maven/src/assembly/maven/bin/mvnup
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 Upgrade 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" --up "$@"
37 changes: 37 additions & 0 deletions apache-maven/src/assembly/maven/bin/mvnup.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@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 Upgrade Script
@REM
@REM Environment Variable Prerequisites
@REM
@REM JAVA_HOME (Optional) Points to a Java installation.
@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 --up %*
9 changes: 5 additions & 4 deletions apache-maven/src/main/appended-resources/META-INF/LICENSE.vm
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@ subject to the terms and conditions of the following licenses:
#* *##set ( $spdx = 'EPL-1.0' )
#* *##elseif ( $license.name == "Eclipse Public License, Version 2.0" )
#* *##set ( $spdx = 'EPL-2.0' )
#* *##elseif ( $license.url.contains( "www.apache.org/licenses/LICENSE-2.0" ) )
#* *##elseif ( $license.url.contains( "www.apache.org/licenses/LICENSE-2.0" )
|| $license.url.contains( "https://raw.github.com/hunterhacker/jdom/master/LICENSE.txt" ) )
#* *##set ( $spdx = 'Apache-2.0' )
#* *##elseif ( $license.name == "BSD-2-Clause" || $license.name == "The BSD 2-Clause License"
|| $license.url.contains("www.opensource.org/licenses/bsd-license") )
|| $license.url.contains( "www.opensource.org/licenses/bsd-license" ) )
#* *##set ( $spdx = 'BSD-2-Clause' )
#* *##elseif ( $license.name == "BSD-3-Clause"
|| $license.url.contains("opensource.org/licenses/BSD-3-Clause") )
|| $license.url.contains( "opensource.org/licenses/BSD-3-Clause" ) )
#* *##set ( $spdx = 'BSD-3-Clause' )
#* *##elseif ( $license.name == "Public Domain" )
#* *##set ( $spdx = 'Public-Domain' )
#* *##elseif ( $license.name == "CDDL + GPLv2 with classpath exception" )
#* *##set ( $spdx = 'CDDL+GPLv2-with-classpath-exception' )
#* *##else
#* *### unrecognized license will require analysis to know obligations
#* *##set ( $spdx = 'unrecognized' )
#* *##set ( $spdx = $license )
#* *##end
#* *###
#* *### fix project urls that are wrong in pom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,30 @@ static Builder mvnsh(@Nonnull List<String> args, @Nonnull MessageBuilderFactory
return builder(Tools.MVNSHELL_CMD, Tools.MVNSHELL_NAME, args, messageBuilderFactory);
}

/**
* Creates a new Builder instance for constructing a Maven Upgrade Tool ParserRequest.
*
* @param args the command-line arguments
* @param messageBuilderFactory the factory for creating message builders
* @return a new Builder instance
*/
@Nonnull
static Builder mvnup(@Nonnull String[] args, @Nonnull MessageBuilderFactory messageBuilderFactory) {
return mvnup(Arrays.asList(args), messageBuilderFactory);
}

/**
* Creates a new Builder instance for constructing a Maven Upgrade Tool ParserRequest.
*
* @param args the command-line arguments
* @param messageBuilderFactory the factory for creating message builders
* @return a new Builder instance
*/
@Nonnull
static Builder mvnup(@Nonnull List<String> args, @Nonnull MessageBuilderFactory messageBuilderFactory) {
return builder(Tools.MVNUP_CMD, Tools.MVNUP_NAME, args, messageBuilderFactory);
}

/**
* Creates a new Builder instance for constructing a ParserRequest.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ private Tools() {}

public static final String MVNSHELL_CMD = "mvnsh";
public static final String MVNSHELL_NAME = "Maven Shell Tool";

public static final String MVNUP_CMD = "mvnup";
public static final String MVNUP_NAME = "Maven Upgrade Tool";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* 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.mvnup;

import java.util.List;
import java.util.Optional;
import java.util.function.UnaryOperator;

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 upgrade tool.
* This interface extends the general {@link Options} interface, adding upgrade-specific configuration options.
*
* @since 4.0.0
*/
@Experimental
public interface UpgradeOptions extends Options {
/**
* Should the operation be forced (ie overwrite existing files, if any).
*
* @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
Optional<Boolean> force();

/**
* Should imply "yes" to all questions.
*
* @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
Optional<Boolean> yes();

/**
* Returns the list of upgrade goals to be executed.
* These goals can include operations like "check", "dependencies", "plugins", etc.
*
* @return an {@link Optional} containing the list of goals, or empty if not specified
*/
@Nonnull
Optional<List<String>> goals();

/**
* Returns the target POM model version for upgrades.
* Supported values include "4.0.0" and "4.1.0".
*
* @return an {@link Optional} containing the model version, or empty if not specified
*/
@Nonnull
Optional<String> modelVersion();

/**
* Returns the directory to use as starting point for POM discovery.
* If not specified, the current directory will be used.
*
* @return an {@link Optional} containing the directory path, or empty if not specified
*/
@Nonnull
Optional<String> directory();

/**
* Should use inference when upgrading (remove redundant information).
*
* @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
@Nonnull
Optional<Boolean> infer();

/**
* Should fix Maven 4 compatibility issues in POMs.
* This includes fixing unsupported combine attributes, duplicate dependencies,
* unsupported expressions, and other Maven 4 validation issues.
*
* @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
@Nonnull
Optional<Boolean> model();

/**
* Should upgrade plugins known to fail with Maven 4 to their minimum compatible versions.
* This includes upgrading plugins like maven-exec-plugin, maven-enforcer-plugin,
* flatten-maven-plugin, and maven-shade-plugin to versions that work with Maven 4.
*
* @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
@Nonnull
Optional<Boolean> plugins();

/**
* Should apply all upgrade options (equivalent to --model-version 4.1.0 --infer --model --plugins).
* This is a convenience option that combines model upgrade, inference, compatibility fixes, and plugin upgrades.
*
* @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
*/
@Nonnull
Optional<Boolean> all();

/**
* Returns a new instance of UpgradeOptions with values interpolated using the given properties.
*
* @param callback a callback to use for interpolation
* @return a new UpgradeOptions instance with interpolated values
*/
@Nonnull
UpgradeOptions interpolate(UnaryOperator<String> callback);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.
*/

/**
* Provides the API for the Maven Upgrade tool ({@code mvnup}).
*
* <p>This package contains interfaces and classes for the Maven upgrade tool,
* which provides functionality for upgrading Maven projects and dependencies.</p>
*
* <p>Key features include:</p>
* <ul>
* <li>Project upgrade capabilities</li>
* <li>Dependency version management</li>
* <li>Configuration migration</li>
* <li>Interactive upgrade workflows</li>
* </ul>
*
* @see org.apache.maven.api.cli.Tools#MVNUP_CMD
* @see org.apache.maven.api.cli.Tools#MVNUP_NAME
* @since 4.0.0
*/
package org.apache.maven.api.cli.mvnup;
23 changes: 13 additions & 10 deletions impl/maven-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ under the License.
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-file</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-jdk</artifactId>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand All @@ -151,6 +159,11 @@ under the License.
<artifactId>plexus-xml</artifactId>
</dependency>

<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
</dependency>

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
Expand Down Expand Up @@ -216,16 +229,6 @@ under the License.
<artifactId>maven-resolver-connector-basic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-file</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-jdk</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-native</artifactId>
Expand Down
Loading