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

org.kuali.common.maven.project.DirectoryContextProvider Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2004-2015 The Kuali Foundation
 *
 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 *
 * 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 org.kuali.common.maven.project;

import static org.kuali.common.jute.base.Precondition.checkNotNull;

import java.io.File;

import javax.inject.Inject;
import javax.inject.Provider;

import org.apache.maven.model.Build;
import org.apache.maven.project.MavenProject;
import org.kuali.common.jute.project.maven.DirectoryContext;
import org.kuali.common.jute.project.maven.DirectoryPair;

public final class DirectoryContextProvider implements Provider {

    @Inject
    public DirectoryContextProvider(MavenProject project) {
        this.project = checkNotNull(project, "project");
    }

    private final MavenProject project;

    @Override
    public DirectoryContext get() {

        Build build = project.getBuild();

        File mainSource = new File(build.getSourceDirectory());
        File mainOutput = new File(build.getOutputDirectory());
        File testSource = new File(build.getTestSourceDirectory());
        File testOutput = new File(build.getTestOutputDirectory());

        DirectoryContext.Builder builder = DirectoryContext.builder();
        builder.withBasedir(project.getBasedir());
        builder.withMain(DirectoryPair.build(mainSource, mainOutput));
        builder.withTest(DirectoryPair.build(testSource, testOutput));
        return builder.build();
    }

    public MavenProject getProject() {
        return project;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy