/*
 * Copyright (c) 2012-2017 Red Hat, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
package org.eclipse.che.dto.generator.maven.plugin;

import java.io.File;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.eclipse.che.dto.generator.DtoGenerator;

/** Mojo to run {@link org.eclipse.che.dto.generator.DtoGenerator}. */
@Mojo(name = "generate", requiresDependencyResolution = ResolutionScope.COMPILE)
public class DtoGeneratorMojo extends AbstractMojo {
  @Parameter(property = "outputDir", required = true)
  private String outputDirectory;

  @Parameter(property = "dtoPackages", required = true)
  private String[] dtoPackages;

  @Parameter(property = "genClassName", required = true)
  private String genClassName;

  @Parameter(property = "impl", required = true)
  private String impl;

  public void execute() throws MojoExecutionException {
    DtoGenerator dtoGenerator = new DtoGenerator();
    dtoGenerator.setPackageBase(outputDirectory);
    String genFileName = genClassName.replace('.', File.separatorChar) + ".java";
    dtoGenerator.setGenFileName(
        outputDirectory.endsWith("/")
            ? (outputDirectory + genFileName)
            : (outputDirectory + File.separatorChar + genFileName));
    dtoGenerator.setImpl(impl);
    dtoGenerator.setDtoPackages(dtoPackages);
    dtoGenerator.generate();
  }
}

@@ -1302,61 +1302,297 @@
 %0A%0A  
-public void execute() throws MojoExecutionException %7B
+/** A flag to disable generation of the DTOs. */%0A  @Parameter(property = %22che.dto.skip%22, defaultValue = %22false%22)%0A  private boolean skip;%0A%0A  @Override%0A  public void execute() throws MojoExecutionException %7B%0A    if (skip) %7B%0A      getLog().info(%22Skipping the execution%22);%0A      return;%0A    %7D%0A
 %0A   

Allow to skip the DTOs generation during maven build (#7348)