Search in sources :

Example 16 with InterpolationException

use of org.codehaus.plexus.interpolation.InterpolationException in project indy by Commonjava.

the class CoreServerFixture method newBootOptions.

private static BootOptions newBootOptions(final File bootDefaults, final String indyHome) {
    final Properties properties = System.getProperties();
    properties.setProperty("indy.home", indyHome);
    System.setProperties(properties);
    try {
        final BootOptions options = new BootOptions("indy", indyHome, bootDefaults);
        options.setPort(findOpenPort(MAX_PORTGEN_TRIES));
        return options;
    } catch (IOException | InterpolationException e) {
        throw new IllegalStateException("Cannot start core Indy server with the given configuration: " + e.getMessage(), e);
    }
}
Also used : IOException(java.io.IOException) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) Properties(java.util.Properties) BootOptions(org.commonjava.propulsor.boot.BootOptions)

Example 17 with InterpolationException

use of org.codehaus.plexus.interpolation.InterpolationException in project maven-plugins by apache.

the class GenerateApplicationXmlMojo method buildEjbEntries.

/**
 * Builds the ejb-ref based on the configuration.
 *
 * @return a list of EjbRef object(s)
 * @throws EarPluginException if the configuration is invalid
 */
private List<EjbRef> buildEjbEntries() throws EarPluginException {
    final List<EjbRef> result = new ArrayList<EjbRef>();
    if (ejbRefs == null) {
        return result;
    }
    try {
        StringSearchInterpolator ssi = new StringSearchInterpolator();
        ValueSource vs = new MapBasedValueSource(project.getProperties());
        ssi.addValueSource(vs);
        final PlexusConfiguration[] allEjbEntries = ejbRefs.getChildren(EjbRef.EJB_REF);
        for (PlexusConfiguration ejbEntry : allEjbEntries) {
            // CHECKSTYLE_OFF: LineLength
            final String childDescription = interpolate(ssi, ejbEntry.getChild(EnvEntry.DESCRIPTION).getValue());
            final String childEjbEntryName = interpolate(ssi, ejbEntry.getChild(EjbRef.EJB_NAME).getValue());
            final String childEjbEntryType = interpolate(ssi, ejbEntry.getChild(EjbRef.EJB_TYPE).getValue());
            final String childEjbLookupNameValue = interpolate(ssi, ejbEntry.getChild(EjbRef.EJB_LOOKUP_NAME).getValue());
            try {
                result.add(new EjbRef(childDescription, childEjbEntryName, childEjbEntryType, childEjbLookupNameValue));
            } catch (IllegalArgumentException e) {
                throw new EarPluginException("Invalid ejb-ref [" + ejbEntry + "]", e);
            }
        }
        return result;
    } catch (InterpolationException e) {
        throw new EarPluginException("Interpolation exception:", e);
    }
}
Also used : PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) ValueSource(org.codehaus.plexus.interpolation.ValueSource) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource) ArrayList(java.util.ArrayList) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource)

Example 18 with InterpolationException

use of org.codehaus.plexus.interpolation.InterpolationException in project maven-plugins by apache.

the class GenerateApplicationXmlMojo method buildResourceRefs.

/**
 * Builds the <code>resource-ref</code> based on the configuration.
 *
 * @return a list of ResourceRef object(s)
 * @throws EarPluginException if the configuration is invalid
 */
private List<ResourceRef> buildResourceRefs() throws EarPluginException {
    final List<ResourceRef> result = new ArrayList<ResourceRef>();
    if (resourceRefs == null) {
        return result;
    }
    try {
        getLog().debug("Resources found");
        StringSearchInterpolator ssi = new StringSearchInterpolator();
        ValueSource vs = new MapBasedValueSource(project.getProperties());
        ssi.addValueSource(vs);
        // TODO: Check if this is a good idea hard code that here? Better idea?
        final PlexusConfiguration[] allResourceRefEntries = resourceRefs.getChildren("resourceRef");
        getLog().debug("allResourceRefEntries: " + allResourceRefEntries);
        getLog().debug("allResourceRefEntries length: " + allResourceRefEntries.length);
        for (PlexusConfiguration resEntry : allResourceRefEntries) {
            getLog().debug("Resources resEntry:" + resEntry.getName());
            // CHECKSTYLE_OFF: LineLength
            final String childResRefName = interpolate(ssi, resEntry.getChild(ResourceRef.RESOURCE_REF_NAME).getValue());
            final String childResType = interpolate(ssi, resEntry.getChild(ResourceRef.RESOURCE_TYPE).getValue());
            final String childResRefAuth = interpolate(ssi, resEntry.getChild(ResourceRef.RESOURCE_AUTH).getValue());
            try {
                result.add(new ResourceRef(childResRefName, childResType, childResRefAuth));
            } catch (IllegalArgumentException e) {
                throw new EarPluginException("Invalid resource-ref [" + resEntry + "]", e);
            }
        }
        return result;
    } catch (InterpolationException e) {
        throw new EarPluginException("Interpolation exception:", e);
    }
}
Also used : PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) ValueSource(org.codehaus.plexus.interpolation.ValueSource) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource) ArrayList(java.util.ArrayList) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource)

Example 19 with InterpolationException

use of org.codehaus.plexus.interpolation.InterpolationException in project maven-plugins by apache.

the class ClassesPackagingTask method generateJarArchive.

/**
 * @param context The warPackingContext.
 * @throws MojoExecutionException In casae of an error.
 */
protected void generateJarArchive(WarPackagingContext context) throws MojoExecutionException {
    MavenProject project = context.getProject();
    ArtifactFactory factory = context.getArtifactFactory();
    Artifact artifact = factory.createBuildArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), "jar");
    String archiveName;
    try {
        archiveName = getArtifactFinalName(context, artifact);
    } catch (InterpolationException e) {
        throw new MojoExecutionException("Could not get the final name of the artifact [" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + "]", e);
    }
    final String targetFilename = LIB_PATH + archiveName;
    if (context.getWebappStructure().registerFile(currentProjectOverlay.getId(), targetFilename)) {
        final File libDirectory = new File(context.getWebappDirectory(), LIB_PATH);
        final File jarFile = new File(libDirectory, archiveName);
        final ClassesPackager packager = new ClassesPackager();
        packager.packageClasses(context.getClassesDirectory(), jarFile, context.getJarArchiver(), context.getSession(), project, context.getArchive());
    } else {
        context.getLog().warn("Could not generate archive classes file [" + targetFilename + "] has already been copied.");
    }
}
Also used : ClassesPackager(org.apache.maven.plugins.war.util.ClassesPackager) ArtifactFactory(org.apache.maven.artifact.factory.ArtifactFactory) MavenProject(org.apache.maven.project.MavenProject) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

InterpolationException (org.codehaus.plexus.interpolation.InterpolationException)19 IOException (java.io.IOException)11 StringSearchInterpolator (org.codehaus.plexus.interpolation.StringSearchInterpolator)10 MapBasedValueSource (org.codehaus.plexus.interpolation.MapBasedValueSource)7 File (java.io.File)6 RegexBasedInterpolator (org.codehaus.plexus.interpolation.RegexBasedInterpolator)5 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 EnvarBasedValueSource (org.codehaus.plexus.interpolation.EnvarBasedValueSource)4 ObjectBasedValueSource (org.codehaus.plexus.interpolation.ObjectBasedValueSource)4 PropertiesBasedValueSource (org.codehaus.plexus.interpolation.PropertiesBasedValueSource)4 PlexusConfiguration (org.codehaus.plexus.configuration.PlexusConfiguration)3 Interpolator (org.codehaus.plexus.interpolation.Interpolator)3 ValueSource (org.codehaus.plexus.interpolation.ValueSource)3 InputStream (java.io.InputStream)2 Artifact (org.apache.maven.artifact.Artifact)2 Activation (org.apache.maven.model.Activation)2 ActivationFile (org.apache.maven.model.ActivationFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1