This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag maven-launchpad-plugin-2.1.2 in repository https://gitbox.apache.org/repos/asf/sling-maven-launchpad-plugin.git
commit bc03898e968409c4cb829df33b4202d4b50938ff Author: Justin Edelson <[email protected]> AuthorDate: Thu Oct 6 17:03:55 2011 +0000 SLING-2238 - doing property interpolation on bundle list git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-launchpad-plugin@1179709 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractUsingBundleListMojo.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java index 60898d6..75bceb5 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java @@ -21,6 +21,7 @@ import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.Reader; +import java.util.Arrays; import java.util.Enumeration; import java.util.List; import java.util.Properties; @@ -40,13 +41,21 @@ import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.settings.Settings; import org.apache.maven.shared.filtering.MavenFileFilter; import org.apache.maven.shared.filtering.MavenFilteringException; import org.apache.maven.shared.filtering.PropertyUtils; +import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle; import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList; +import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel; import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleListXpp3Reader; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.zip.ZipUnArchiver; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; +import org.codehaus.plexus.interpolation.PropertiesBasedValueSource; +import org.codehaus.plexus.interpolation.StringSearchInterpolator; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; @@ -422,9 +431,53 @@ public abstract class AbstractUsingBundleListMojo extends AbstractBundleListMojo initBundleList(bundleList); + interpolateProperties(bundleList); + rewriteBundleList(bundleList); } + private void interpolateProperties(BundleList bundleList) throws MojoExecutionException { + Interpolator interpolator = createInterpolator(); + for (final StartLevel sl : bundleList.getStartLevels()) { + for (final Bundle bndl : sl.getBundles()) { + try { + bndl.setArtifactId(interpolator.interpolate(bndl.getArtifactId())); + bndl.setGroupId(interpolator.interpolate(bndl.getGroupId())); + bndl.setVersion(interpolator.interpolate(bndl.getVersion())); + bndl.setClassifier(interpolator.interpolate(bndl.getClassifier())); + bndl.setType(interpolator.interpolate(bndl.getType())); + } catch (InterpolationException e) { + throw new MojoExecutionException("Unable to interpolate properties for bundle " + bndl.toString(), e); + } + } + } + + } + + private Interpolator createInterpolator() { + StringSearchInterpolator interpolator = new StringSearchInterpolator(); + + final Properties props = new Properties(); + props.putAll(project.getProperties()); + props.putAll(mavenSession.getExecutionProperties()); + + interpolator.addValueSource(new PropertiesBasedValueSource(props)); + + // add ${project.foo} + interpolator.addValueSource(new PrefixedObjectValueSource(Arrays.asList("project", "pom"), project, true)); + + // add ${session.foo} + interpolator.addValueSource(new PrefixedObjectValueSource("session", mavenSession)); + + // add ${settings.foo} + final Settings settings = mavenSession.getSettings(); + if (settings != null) { + interpolator.addValueSource(new PrefixedObjectValueSource("settings", settings)); + } + + return interpolator; + } + private void rewriteBundleList(BundleList bundleList) throws MojoExecutionException { if (rewriteRuleFiles != null) { KnowledgeBase knowledgeBase = createKnowledgeBase(rewriteRuleFiles); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
