Java tutorial
/* * Copyright (C) 2013 Push Technology Ltd. * * 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.pushtechnology.mvndar; import static com.pushtechnology.mvndar.DARMojo.or; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; import org.codehaus.plexus.archiver.util.DefaultFileSet; /** * Add the project output to the {@code ext} directory. * * @author Philip Aston */ class AddProjectOutputTask implements PackagingTask { private static final String[] DEFAULT_INCLUDES = new String[] { "**" }; private static final String[] DEFAULT_EXCLUDES = new String[] {}; @Override public void perform(final DARMojoContext context) throws IOException { final File outputDirectory = context.getOutputDirectory(); if (outputDirectory.exists()) { final DefaultFileSet fileSet = new DefaultFileSet(); fileSet.setDirectory(context.getOutputDirectory()); fileSet.setIncludes(or(context.getOutputIncludes(), DEFAULT_INCLUDES)); fileSet.setExcludes(or(context.getOutputExcludes(), DEFAULT_EXCLUDES)); final File target = FileUtils.getFile(context.getPrefixDirectoryName(), context.getExtDirectoryName()); fileSet.setPrefix(target.toString() + File.separator); context.getArchiver().addFileSet(fileSet); } else { context.getLog().warn(outputDirectory + " does not exist, skipping"); } } }