Skip to content

Commit

Permalink
config fix (using temporary snippet and not relying on project config)
Browse files Browse the repository at this point in the history
  • Loading branch information
mepeisen committed Apr 24, 2012
1 parent e988fc5 commit 5f5be7f
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package org.phpmaven.plugin.phar;

import java.io.File;
import java.io.IOException;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.phpmaven.core.IComponentFactory;
import org.phpmaven.exec.PhpException;
import org.phpmaven.phar.IPharPackagerConfiguration;
Expand Down Expand Up @@ -68,8 +70,19 @@ public void execute() throws MojoExecutionException, MojoFailureException {
throw new MojoExecutionException("phar file " + this.phar + " is a directory");
}
try {
final File tmpSnippet = File.createTempFile("snippet", ".php");
tmpSnippet.deleteOnExit();

final Xpp3Dom configNode = new Xpp3Dom("configuration");
final Xpp3Dom execConfigNode = new Xpp3Dom("executableConfig");
final Xpp3Dom fileNode = new Xpp3Dom("temporaryScriptFile");
fileNode.setValue(tmpSnippet.getAbsolutePath());
execConfigNode.addChild(fileNode);
configNode.addChild(execConfigNode);

final IPharPackagerConfiguration config = this.factory.lookup(
IPharPackagerConfiguration.class, IComponentFactory.EMPTY_CONFIG, this.session);
IPharPackagerConfiguration.class, configNode, this.session);

final Iterable<String> contents = config.getPharPackager().listFiles(this.phar, this.getLog());
getLog().info("contents of phar file " + this.phar);
for (final String f : contents) {
Expand All @@ -81,6 +94,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
throw new MojoExecutionException("failed executing list-phar-files", ex);
} catch (PhpException ex) {
throw new MojoExecutionException("failed executing list-phar-files", ex);
} catch (IOException ex) {
throw new MojoExecutionException("failed executing list-phar-files", ex);
}
}

Expand Down

0 comments on commit 5f5be7f

Please sign in to comment.