/*
 * Copyright 2013-2016 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.<br><br>
 * Helper mojo.<br>
 * Adds {@code ${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 <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
 * @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.
     * 
     * {@code ${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 );
        }
    }

}

@@ -1058,23 +1058,22 @@
  * Adds 
-%7B@
+%3C
 code
- 
+%3E
 $%7Bprojec
@@ -1102,17 +1102,23 @@
 _managed
-%7D
+%3C/code%3E
  as comp
@@ -1724,15 +1724,14 @@
   * 
-%7B@
+%3C
 code
- 
+%3E
 $%7Bpr
@@ -1764,17 +1764,23 @@
 _managed
-%7D
+%3C/code%3E
  is adde

Fix mojo description containing "${project.build.directory}" variable.