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

com.google.code.sbt.compiler.plugin.SBTAddManagedSourcesMojo Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot 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.google.code.sbt.compiler.plugin;

import java.io.File;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

/**
 * Add managed source root, if it is not already added.

* Helper mojo.
* Adds ${project.build.directory}/src_managed as compile source root * even if it does not exist yet (it may be created later by source generators). * * @author Grzegorz Slowikowski * @since 1.0.0 */ @Mojo( name = "addManagedSources", defaultPhase = LifecyclePhase.INITIALIZE ) public class SBTAddManagedSourcesMojo extends AbstractMojo { /** * Maven project to interact with. */ @Parameter( defaultValue = "${project}", readonly = true, required = true ) protected MavenProject project; /** * Adds default SBT managed sources location to Maven project. * * ${project.build.directory}/src_managed is added to project's compile source roots */ @Override public void execute() { if ( "pom".equals( project.getPackaging() ) ) { return; } File managedPath = new File( project.getBuild().getDirectory(), "src_managed" ); String managedPathStr = managedPath.getAbsolutePath(); if ( !project.getCompileSourceRoots().contains( managedPathStr ) ) { project.addCompileSourceRoot( managedPathStr ); getLog().debug( "Added source directory: " + managedPathStr ); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy