Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Print bugzilla link when running Maven plugin, and add deprecation wa…
Browse files Browse the repository at this point in the history
…rnings
  • Loading branch information
seanf committed Jul 20, 2012
1 parent 881c6b1 commit c80dad6
Show file tree
Hide file tree
Showing 18 changed files with 127 additions and 18 deletions.
Expand Up @@ -33,6 +33,8 @@ public abstract class ConfigurableCommand<O extends ConfigurableOptions> impleme
{
private final O opts;
private ZanataProxyFactory requestFactory;
private boolean deprecated;
private String deprecationMessage;

public ConfigurableCommand(O opts, ZanataProxyFactory factory)
{
Expand All @@ -58,4 +60,28 @@ public ZanataProxyFactory getRequestFactory()
return requestFactory;
}

@Override
public boolean isDeprecated()
{
return deprecated;
}

@Override
public String getDeprecationMessage()
{
return this.deprecationMessage;
}

public void deprecate(String deprecationMessage)
{
this.deprecated = true;
this.deprecationMessage = deprecationMessage;
}

@Override
public String getName()
{
return opts.getCommandName();
}

}
Expand Up @@ -44,6 +44,7 @@ public PublicanPullCommand(PublicanPullOptions opts, ZanataProxyFactory factory,
this.sourceDocResource = sourceDocResource;
this.translationResources = translationResources;
this.uri = uri;
deprecate("please use \"pull\" with project type \"" + PROJECT_TYPE_PUBLICAN + "\"");
}

private PublicanPullCommand(PublicanPullOptions opts, ZanataProxyFactory factory)
Expand Down
Expand Up @@ -55,6 +55,7 @@ public PublicanPushCommand(PublicanPushOptions opts, ZanataProxyFactory factory,
this.sourceDocResource = sourceDocResource;
this.translationResources = translationResources;
this.uri = uri;
deprecate("please use \"push\" with project type \"" + PROJECT_TYPE_PUBLICAN + "\"");
}

private PublicanPushCommand(PublicanPushOptions opts, ZanataProxyFactory factory)
Expand Down
Expand Up @@ -10,4 +10,21 @@ public interface ZanataCommand
*/
public void run() throws Exception;

/**
* Returns true if the command has been deprecated.
* @return
*/
boolean isDeprecated();

/**
* If the command has been deprecated, returns a message (eg a command which replaces the deprecated command).
* @return
*/
String getDeprecationMessage();

/**
* Returns the command name (eg Maven goal name)
* @return
*/
String getName();
}
Expand Up @@ -6,8 +6,6 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zanata.client.commands.ConfigurableCommand;
import org.zanata.client.commands.ConfigurableOptions;
import org.zanata.client.commands.OptionsUtil;
Expand All @@ -24,7 +22,7 @@
*/
public abstract class ConfigurableMojo<O extends ConfigurableOptions> extends AbstractMojo implements ConfigurableOptions
{
private static final Logger log = LoggerFactory.getLogger(ConfigurableMojo.class);
private static final String BUG_URL = "https://bugzilla.redhat.com/enter_bug.cgi?format=guided&product=Zanata";

// @formatter:off
/*
Expand Down Expand Up @@ -126,6 +124,7 @@ public void execute() throws MojoExecutionException, MojoFailureException
MavenLogAppender.startPluginLog(this);
try
{
getLog().info("Please report Zanata bugs here: " + BUG_URL);
OptionsUtil.applyConfigFiles(this);
runCommand();
}
Expand All @@ -142,6 +141,20 @@ public void execute() throws MojoExecutionException, MojoFailureException
protected void runCommand() throws Exception
{
ZanataCommand command = initCommand();
String name = command.getName();
getLog().info("Zanata command: " + name);
if (command.isDeprecated())
{
String msg = command.getDeprecationMessage();
if (msg != null)
{
getLog().warn("Command \"" + name + "\" has been deprecated: " + msg);
}
else
{
getLog().warn("Command \"" + name + "\" has been deprecated");
}
}
command.run();
}

Expand All @@ -159,7 +172,7 @@ public boolean getDebug()
@Override
public void setDebug(boolean debug)
{
log.info("ignoring setDebug: use mvn -X to control debug logging");
getLog().info("ignoring setDebug: use mvn -X to control debug logging");
}

@Override
Expand All @@ -171,7 +184,7 @@ public boolean getErrors()
@Override
public void setErrors(boolean errors)
{
log.info("ignoring setErrors: use mvn -e to control exception logging");
getLog().info("ignoring setErrors: use mvn -e to control exception logging");
}

@Override
Expand All @@ -195,7 +208,7 @@ public boolean getQuiet()
@Override
public void setQuiet(boolean quiet)
{
log.info("ignoring setQuiet: use mvn -q to set quiet logging mode");
getLog().info("ignoring setQuiet: use mvn -q to set quiet logging mode");
}

// maven controls logging, so there's no point in changing these values
Expand Down Expand Up @@ -236,13 +249,6 @@ public String getCommandDescription()
throw new UnsupportedOperationException();
}

@Override
public String getCommandName()
{
throw new UnsupportedOperationException();
}


@Override
public String getKey()
{
Expand Down
Expand Up @@ -67,6 +67,11 @@ public GlossaryDeleteCommand initCommand()
return new GlossaryDeleteCommand(this);
}

@Override
public String getCommandName()
{
return "glossary-delete";
}

}

Expand Down
Expand Up @@ -142,6 +142,12 @@ public int getBatchSize()
{
return batchSize;
}

@Override
public String getCommandName()
{
return "glossary-push";
}
}


Expand Down
Expand Up @@ -25,4 +25,9 @@ public ListLocalCommand initCommand()
return new ListLocalCommand(this);
}

@Override
public String getCommandName()
{
return "list-local";
}
}
Expand Up @@ -31,5 +31,11 @@ public String getProjectType()
{
return ZANATA_SERVER_PROJECT_TYPE;
}

@Override
public String getCommandName()
{
return "listremote";
}

}
Expand Up @@ -91,5 +91,11 @@ public void setExportPot(boolean exportPot)
{
this.exportPot = exportPot;
}

@Override
public String getCommandName()
{
return "publican-pull";
}

}
Expand Up @@ -124,4 +124,9 @@ public String getMergeType()
return merge;
}

@Override
public String getCommandName()
{
return "publican-push";
}
}
Expand Up @@ -132,4 +132,10 @@ public LocaleList getLocaleMapList()
return effectiveLocales;
}

@Override
public String getCommandName()
{
return "pull";
}

}
Expand Up @@ -240,4 +240,10 @@ public LocaleList getLocaleMapList()

return effectiveLocales;
}

@Override
public String getCommandName()
{
return "push";
}
}
Expand Up @@ -79,4 +79,9 @@ public void setProjectDesc(String projectDesc)
}


@Override
public String getCommandName()
{
return "putproject";
}
}
Expand Up @@ -168,4 +168,9 @@ public void setUserDisabled(boolean userDisabled)
this.userDisabled = userDisabled;
}

@Override
public String getCommandName()
{
return "putuser";
}
}
Expand Up @@ -61,4 +61,9 @@ public void setVersionSlug(String versionSlug)
this.versionSlug = versionSlug;
}

@Override
public String getCommandName()
{
return "putversion";
}
}
Expand Up @@ -2,14 +2,11 @@

import java.util.Arrays;

import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.zanata.client.commands.push.PushCommand;
import org.zanata.client.commands.push.PushPullType;

public class PushMojoTest extends ZanataMojoTest<PushMojo, PushCommand>
{
IMocksControl control = EasyMock.createControl();
PushCommand mockCommand = control.createMock(PushCommand.class);
PushMojo pushMojo = new PushMojo()
{
Expand Down Expand Up @@ -41,7 +38,6 @@ protected void setUp() throws Exception
{
// required for mojo lookups to work
super.setUp();
control.reset();
}

@Override
Expand Down Expand Up @@ -72,7 +68,7 @@ public void testPomConfig() throws Exception

/**
* Test that the pom.xml settings are applied as expected using the pushType
* mojo paramater,
* mojo parameter,
*
* @throws Exception
*/
Expand Down
Expand Up @@ -22,6 +22,8 @@ protected void setUp() throws Exception
// required for mojo lookups to work
super.setUp();
control.reset();
EasyMock.expect(getMockCommand().getName()).andReturn("mockCommand").anyTimes();
EasyMock.expect(getMockCommand().isDeprecated()).andReturn(false).anyTimes();
}

@Override
Expand Down

0 comments on commit c80dad6

Please sign in to comment.