All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.marvelution.utils.maven.project.ProjectUtils Maven / Gradle / Ivy

/*
 * Copyright 2008 Marvelution.com
 *
 * 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.
 */

package com.marvelution.utils.maven.project;

import java.io.File;
import java.io.IOException;

import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

import com.marvelution.utils.maven.model.ModelUtils;

/**
 * Utility class for Maven Projects
 * 
 * @author Mark Rekveld
 */
public final class ProjectUtils {

	/**
	 * Helper method to create a {@link MavenProject} from a {@link Model} in a POM {@link File}
	 * 
	 * @param pomFile the POM {@link File}
	 * @return the {@link MavenProject}
	 * @throws XmlPullParserException in case fo Model parse exceptions
	 * @throws IOException in case of read exception
	 */
	public static MavenProject createMavenProject(File pomFile) throws IOException, XmlPullParserException {
		final Model model = ModelUtils.read(pomFile);
		final MavenProject project = new MavenProject(model);
		project.setFile(pomFile);
		return project;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy