eu.cedarsoft.devtools.modules.CreateIdeaProjectModule Maven / Gradle / Ivy
The newest version!
package eu.cedarsoft.devtools.modules;
import com.google.inject.Inject;
import eu.cedarsoft.devtools.CommandLineContext;
import eu.cedarsoft.devtools.MavenMessageHandler;
import eu.cedarsoft.devtools.MavenSupport;
import eu.cedarsoft.devtools.Module;
import eu.cedarsoft.devtools.ProcessWrapper;
import eu.cedarsoft.devtools.ModuleFailedException;
import eu.cedarsoft.utils.CmdLine;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
/**
* Creates an idea project
*/
public class CreateIdeaProjectModule implements Module {
@NotNull
private final CommandLineContext commandLineContext;
@NotNull
private final MavenSupport mavenSupport;
/**
* Creates an idea module
*
* @param mavenSupport the maven support
* @param commandLineContext the command line context
*/
@Inject
public CreateIdeaProjectModule( @NotNull MavenSupport mavenSupport, @NotNull CommandLineContext commandLineContext ) {
this.mavenSupport = mavenSupport;
this.commandLineContext = commandLineContext;
}
@NotNull
public String getDescription() {
return MavenMessageHandler.get( "module.create.idea.project" );
}
public void process( @NotNull CmdLine cmdLine ) throws IOException, ModuleFailedException {
cmdLine.out( MavenMessageHandler.get( "create.idea.project" ) );
mavenSupport.ensurePomExists( new File( "." ) );
cmdLine.warning( MavenMessageHandler.get( "creating.idea.project" ) );
cmdLine.out( MavenMessageHandler.get( "with.projectId" ) );
ProcessWrapper.runCommand( cmdLine, mavenSupport.getMavenBin() + " idea:idea -DdownloadSources=true -DdownloadJavadoc=true " + commandLineContext.getCmdLineArgs() );
cmdLine.success( MavenMessageHandler.get( "module.processed.successfully" ) );
}
}