Skip to content

Commit

Permalink
FORGE-2272: Using Forge version instead of Furnace's
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Mar 6, 2015
1 parent 2e76d74 commit cc0cd5b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import org.jboss.forge.furnace.Furnace;
import org.jboss.forge.furnace.exception.ContainerException;
import org.jboss.forge.furnace.spi.ContainerLifecycleListener;
import org.jboss.forge.furnace.versions.EmptyVersion;
import org.jboss.forge.furnace.versions.SingleVersion;
import org.jboss.forge.furnace.versions.Version;
import org.jboss.forge.furnace.versions.Versions;

public class GreetingListener implements ContainerLifecycleListener
{
Expand All @@ -35,7 +39,7 @@ public void beforeStart(Furnace furnace) throws ContainerException
out.println(" |__/ ");
out.println("");
out.print("JBoss Forge, version [ ");
out.print(furnace.getVersion());
out.print(getForgeVersion());
out.print(" ] - JBoss, by Red Hat, Inc. [ http://forge.jboss.org ]");
out.println();
logger.info(sw.toString());
Expand Down Expand Up @@ -73,4 +77,23 @@ public void afterConfigurationScan(Furnace furnace) throws ContainerException
// Do nothing
}

/**
* Returns the Implementation version for the given {@link Class}
*
* TODO: Use the {@link Versions} class when Forge is updated to Furnace 2.15.3.Final+
*
* @param type the {@link Class} with the corresponding package
* @return {@link Version} representation from the {@link Package#getImplementationVersion()} returned from
* {@link Class#getPackage()}
*/
private Version getForgeVersion()
{
String version = getClass().getPackage().getImplementationVersion();
if (version != null)
{
return new SingleVersion(version);
}

return EmptyVersion.getInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,25 @@

package org.jboss.forge.addon.shell.command;

import javax.inject.Inject;

import org.jboss.forge.addon.ui.annotation.Command;
import org.jboss.forge.addon.ui.annotation.predicate.NonGUIEnabledPredicate;
import org.jboss.forge.addon.ui.output.UIOutput;
import org.jboss.forge.furnace.Furnace;
import org.jboss.forge.furnace.versions.EmptyVersion;
import org.jboss.forge.furnace.versions.SingleVersion;
import org.jboss.forge.furnace.versions.Version;
import org.jboss.forge.furnace.versions.Versions;

/**
* The "About" command
*
* @author <a href="ggastald@redhat.com">George Gastaldi</a>
*/
public class AboutCommand
{
@Inject
Furnace furnace;

@Command(value = "version", help = "Displays the current Forge version.", enabled = NonGUIEnabledPredicate.class)
public void showVersion(final UIOutput output)
{
Version version = furnace.getVersion();
Version version = getForgeVersion();
output.out().println(
"JBoss Forge, version [ " + version + " ] - JBoss, by Red Hat, Inc. [ http://jboss.org/forge ]");
}
Expand All @@ -45,4 +43,25 @@ public void showAbout(final UIOutput output)
output.out().println("");
showVersion(output);
}

/**
* Returns the Implementation version for the given {@link Class}
*
* TODO: Use the {@link Versions} class when Forge is updated to Furnace 2.15.3.Final+
*
* @param type the {@link Class} with the corresponding package
* @return {@link Version} representation from the {@link Package#getImplementationVersion()} returned from
* {@link Class#getPackage()}
*/
private Version getForgeVersion()
{
String version = getClass().getPackage().getImplementationVersion();
if (version != null)
{
return new SingleVersion(version);
}

return EmptyVersion.getInstance();
}

}

0 comments on commit cc0cd5b

Please sign in to comment.