![JAR search and dependency download from the Maven repository](/logo.png)
com.marvelution.maven.components.migration.manager.environment.MigrationEnvironment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-migration-manager Show documentation
Show all versions of maven-migration-manager Show documentation
Maven 2.x Plexus Migration Manager Component used by the maven-migrator-plugin
The newest version!
/*
* Licensed to Marvelution under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Marvelution 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 com.marvelution.maven.components.migration.manager.environment;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import com.marvelution.utils.StringUtils;
/**
* Migration Environment
*
* @author Mark Rekveld
*/
public class MigrationEnvironment {
/**
* Default maven executor id
*/
public static final String DEFAULT_MAVEN_EXECUTOR_ID = "invoker";
/**
* Maven home directory
*/
private File mavenHome;
/**
* Java home directory
*/
private File javaHome;
/**
* Maven {@link Settings}
*/
private Settings mavenSettings;
/**
* Local {@link ArtifactRepository}
*/
private ArtifactRepository localRepository;
/**
* {@link List} with remote ArtifactRepositories
*/
private List remoteRepositories;
/**
* Maven executor id
*/
private String mavenExecutorId = DEFAULT_MAVEN_EXECUTOR_ID;
/**
* Gets Maven Home
*
* @return maven home directory
*/
public File getMavenHome() {
if (mavenHome == null) {
try {
final Properties envars = CommandLineUtils.getSystemEnvVars();
final String home = envars.getProperty("M2_HOME");
if (StringUtils.isNotEmpty(home)) {
mavenHome = new File(home);
}
} catch (IOException e) {
// MAYBE Handle exception
}
}
return mavenHome;
}
/**
* Sets maven home directory
*
* @param mavenHome the maven home directory
*/
public void setMavenHome(File mavenHome) {
this.mavenHome = mavenHome;
}
/**
* Gets Java home directory
*
* @return the Java home directory
*/
public File getJavaHome() {
if (javaHome == null) {
try {
final Properties envars = CommandLineUtils.getSystemEnvVars();
final String home = envars.getProperty("JAVA_HOME");
if (StringUtils.isNotEmpty(home)) {
javaHome = new File(home);
}
} catch (IOException e) {
// MAYBE Handle exception
}
}
return javaHome;
}
/**
* Sets Java home directory
*
* @param javaHome the Java home directory
*/
public void setJavaHome(File javaHome) {
this.javaHome = javaHome;
}
/**
* Gets Maven {@link Settings}
*
* @return the {@link Settings}
*/
public Settings getMavenSettings() {
return mavenSettings;
}
/**
* Sets the Maven {@link Settings}
*
* @param mavenSettings the Maven {@link Settings}
*/
public void setMavenSettings(Settings mavenSettings) {
this.mavenSettings = mavenSettings;
}
/**
* Gets local repository
*
* @return the local repository
*/
public ArtifactRepository getLocalRepository() {
return localRepository;
}
/**
* Sets the base directory of the local Maven repository
*
* @param localRepository the base directory of the local repository
*/
public void setLocalRepository(ArtifactRepository localRepository) {
this.localRepository = localRepository;
}
/**
* Gets the {@link List} of remote repositories
*
* @return the remoteRepositories
*/
public List getRemoteRepositories() {
if (remoteRepositories == null) {
remoteRepositories = new ArrayList();
}
return remoteRepositories;
}
/**
* Sets the {@link List} of remote repositories
*
* @param remoteRepositories the remoteRepositories to set
*/
public void setRemoteRepositories(List remoteRepositories) {
this.remoteRepositories = remoteRepositories;
}
/**
* Gets the Maven executor Id
*
* @return the Maven executor Id
*/
public String getMavenExecutorId() {
return mavenExecutorId;
}
/**
* Sets the Maven executor Id
*
* @param mavenExecutorId the Maven executor Id to set
*/
public void setMavenExecutorId(String mavenExecutorId) {
this.mavenExecutorId = mavenExecutorId;
}
/**
* Gets interactivity from Maven {@link Settings}
*
* @return true
is interactive, false
is batch-mode
*/
public boolean isInteractive() {
return mavenSettings.isInteractiveMode();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy