/* * Copyright 2007 the original author or authors. * * 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.octo.mtg.plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import java.io.File; /** * Set sources/tests directories to be compatible with the directories layout used by grails. * * @author Arnaud HERITIER * @version $Id$ * @description Set sources/tests directories to be compatible with the directories layout used by grails. * @goal config-directories * @phase generate-sources * @since 0.3 */ public class MvnConfigDirectoriesMojo extends AbstractGrailsMojo { /** * @parameter expression="${project}" * @required * @readonly */ private MavenProject project; /* * (non-Javadoc) * * @see org.apache.maven.plugin.Mojo#execute() */ public void execute() throws MojoExecutionException, MojoFailureException { // Add sources directories this.project.addCompileSourceRoot((new File(this.project.getBasedir(), "/grails-app/conf")).getAbsolutePath()); this.project.addCompileSourceRoot((new File(this.project.getBasedir(), "/grails-app/controllers")).getAbsolutePath()); this.project.addCompileSourceRoot((new File(this.project.getBasedir(), "/grails-app/domain")).getAbsolutePath()); this.project.addCompileSourceRoot((new File(this.project.getBasedir(), "/grails-app/services")).getAbsolutePath()); this.project.addCompileSourceRoot((new File(this.project.getBasedir(), "/grails-app/taglib")).getAbsolutePath()); this.project.addCompileSourceRoot((new File(this.project.getBasedir(), "/grails-app/utils")).getAbsolutePath()); this.project.addCompileSourceRoot((new File(this.project.getBasedir(), "/src/groovy")).getAbsolutePath()); this.project.addCompileSourceRoot((new File(this.project.getBasedir(), "/src/java")).getAbsolutePath()); // Add tests directories this.project.addTestCompileSourceRoot((new File(this.project.getBasedir(), "/test/unit")).getAbsolutePath()); this.project.addTestCompileSourceRoot((new File(this.project.getBasedir(), "/test/integration")).getAbsolutePath()); // Change output dir this.project.getModel().getBuild().setOutputDirectory("web-app/WEB-INF/classes"); } }