Search in sources :

Example 1 with PathResolver

use of org.jboss.galleon.diff.FsDiff.PathResolver in project galleon by wildfly.

the class GetChangesCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    try {
        ProvisioningManager mgr = getManager(invoc.getPmSession());
        FsDiff diff = mgr.getFsDiff();
        if (diff.isEmpty()) {
            invoc.println("No changes detected");
        } else {
            Path workingDir = Paths.get(invoc.getConfiguration().getAeshContext().getCurrentWorkingDirectory().getAbsolutePath());
            Path installation = mgr.getInstallationHome();
            PathResolver resolver = new PathResolver() {

                @Override
                public String resolve(String relativePath) {
                    Path absPath = Paths.get(installation.toString(), relativePath);
                    return workingDir.relativize(absPath).toString();
                }
            };
            FsDiff.log(diff, new Consumer<String>() {

                @Override
                public void accept(String msg) {
                    invoc.println(msg);
                }
            }, resolver);
        }
    } catch (ProvisioningException ex) {
        throw new CommandExecutionException(ex.getMessage());
    }
}
Also used : Path(java.nio.file.Path) ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) FsDiff(org.jboss.galleon.diff.FsDiff) PathResolver(org.jboss.galleon.diff.FsDiff.PathResolver) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException)

Aggregations

Path (java.nio.file.Path)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ProvisioningManager (org.jboss.galleon.ProvisioningManager)1 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)1 FsDiff (org.jboss.galleon.diff.FsDiff)1 PathResolver (org.jboss.galleon.diff.FsDiff.PathResolver)1