Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.chaschev.install;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed 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.
*/
import com.chaschev.chutils.util.OpenBean2;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.DefaultMaven;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.resolution.ArtifactResult;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.eclipse.aether.resolution.DependencyResult;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.text.MessageFormat;
import java.util.*;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Lists.transform;
import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX;
@Mojo(name = "install", requiresProject = false, threadSafe = true)
public class InstallMojo extends AbstractExecMojo {
public static final Function PATH_TO_FILE = new Function() {
public File apply(String s) {
return new File(s);
}
};
public static final class MatchingPath implements Comparable {
int priority;
String path;
public MatchingPath(int priority, String path) {
this.priority = priority;
this.path = path;
}
@Override
public int compareTo(MatchingPath o) {
return priority - o.priority;
}
}
@Parameter(property = "installTo")
private String installTo;
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// FindAvailableVersions.main(null);
initialize();
Artifact artifact = new DefaultArtifact(artifactName);
DependencyResult dependencyResult = resolveArtifact(artifact);
artifact = dependencyResult.getRoot().getArtifact();
List dependencies = dependencyResult.getArtifactResults();
if (className != null) {
new ExecObject(getLog(),
artifact, dependencies, className,
parseArgs(),
systemProperties
).execute();
}
Class> installation = new URLClassLoader(new URL[]{artifact.getFile().toURI().toURL()}).loadClass("Installation");
List