Skip to content

Commit

Permalink
[#14] initial draft for a Mojo.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarwell committed Apr 24, 2022
1 parent 861c4a7 commit 90a6b19
Show file tree
Hide file tree
Showing 26 changed files with 83 additions and 285 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<settingsFile>src/it/settings.xml</settingsFile>
<settingsFile>src/old_it/settings.xml</settingsFile>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;

import java.io.File;
import java.text.MessageFormat;
import java.util.ResourceBundle;

Expand Down Expand Up @@ -49,6 +50,13 @@ public abstract class AbstractKeyToolMojo
@Parameter( defaultValue = "false" )
private boolean verbose;

/**
* Where to execute the keytool command.
*/
@Parameter( defaultValue = "${basedir}", required = true, alias = "workingdir" )
private File workingDirectory;


/**
* @return value of the {@link #skip} flag
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@
* limitations under the License.
*/

import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.shared.utils.cli.Commandline;
import org.codehaus.plexus.util.StringUtils;

import java.io.File;
import java.net.MalformedURLException;

import org.apache.maven.plugins.annotations.Parameter;

/**
* Abstract mojo to execute a {@link KeyToolRequestWithKeyStoreParameters} request.
* Abstract mojo to execute a Keytool with Store Parameters request.
*
* @param <R> generic type of request used by the mojo
* @author tchemit <[email protected]>
* @since 1.2
*/
public abstract class AbstractKeyToolRequestWithKeyStoreParametersMojo<R extends KeyToolRequestWithKeyStoreParameters>
extends AbstractKeyToolRequestMojo<R>
public abstract class AbstractKeyToolRequestWithKeyStoreParametersMojo
extends AbstractKeyToolMojo
{

/**
Expand Down Expand Up @@ -100,56 +97,10 @@ public abstract class AbstractKeyToolRequestWithKeyStoreParametersMojo<R extends

/**
* Constructor of abstract mojo.
*
* @param requestType type of keytool request used by the mojo
*/
public AbstractKeyToolRequestWithKeyStoreParametersMojo( Class<R> requestType )
{
super( requestType );
}

/**
* {@inheritDoc}
*/
@Override
protected R createKeytoolRequest()
{
R request = super.createKeytoolRequest();

if ( StringUtils.isNotEmpty( keystore ) )
{

File file = getFile( keystore );

// make sure the parent directory of the keystore exists

boolean mkdirs = file.getParentFile().mkdirs();
getLog().debug( "mdkirs: " + mkdirs + " " + file.getParentFile() );

// force to not use this parameter
request.setKeystore( file.getAbsolutePath() );
}

request.setProviderarg( providerarg );
request.setProviderclass( providerclass );
request.setProvidername( providername );
request.setProviderpath( providerpath );
request.setStorepass( storepass );
request.setStoretype( storetype );
return request;
}

/**
* {@inheritDoc}
*/
@Override
protected String getCommandlineInfo( final Commandline commandLine )
public AbstractKeyToolRequestWithKeyStoreParametersMojo()
{
String commandLineInfo = super.getCommandlineInfo( commandLine );

commandLineInfo = StringUtils.replace( commandLineInfo, this.storepass, "'*****'" );

return commandLineInfo;
}

/**
Expand Down Expand Up @@ -187,6 +138,16 @@ protected File getFile( String path )

protected File getKeystoreFile()
{
return getFile(keystore);
return getFile( keystore );
}

public String getStoretype()
{
return storetype;
}

public String getStorepass()
{
return storepass;
}
}
Loading

0 comments on commit 90a6b19

Please sign in to comment.