com.marvelution.utils.maven.model.BuildUtils 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.model;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.maven.model.Build;
import org.apache.maven.model.Resource;
import org.codehaus.plexus.util.StringUtils;
/**
* Maven Model Build Utility class
*
* @author Mark Rekveld
*/
public final class BuildUtils {
/**
* Creates a Maven {@link Build} model object
*
* @param source the source directory name
* @param testSource the test-source directory name
* @param resources {@link List} of resource directories
* @param testResources {@link List} of test resource directories
* @return the created {@link Build}
*/
public static Build createBuildAndSetDirectories(String source, String testSource, List resources,
List testResources) {
final Build build = new Build();
if (!StringUtils.isEmpty(source)) {
build.setSourceDirectory(source);
}
if (!StringUtils.isEmpty(testSource)) {
build.setTestSourceDirectory(testSource);
}
build.setResources(createBuildResources(resources));
build.setTestResources(createBuildResources(testResources));
return build;
}
/**
* Creates a {@link List} with {@link Resource} elements
*
* @param resources {@link List} of directory names
* @return the created {@link List}
*/
public static List createBuildResources(List resources) {
final List res = new ArrayList();
for (final Iterator iter = resources.iterator(); iter.hasNext();) {
final String dir = (String) iter.next();
if (!StringUtils.isEmpty(dir)) {
final Resource resource = new Resource();
resource.setDirectory(dir);
res.add(resource);
}
}
return res;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy