Search in sources :

Example 1 with RecursionInterceptor

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

the class DefaultAssemblyReader method readAssembly.

public Assembly readAssembly(Reader reader, final String locationDescription, final File assemblyDir, final AssemblerConfigurationSource configSource) throws AssemblyReadException, InvalidAssemblerConfigurationException {
    Assembly assembly;
    final MavenProject project = configSource.getProject();
    try {
        InterpolationState is = new InterpolationState();
        final RecursionInterceptor interceptor = new PrefixAwareRecursionInterceptor(InterpolationConstants.PROJECT_PREFIXES, true);
        is.setRecursionInterceptor(interceptor);
        FixedStringSearchInterpolator interpolator = AssemblyInterpolator.fullInterpolator(project, createProjectInterpolator(project), configSource);
        AssemblyXpp3Reader.ContentTransformer transformer = AssemblyInterpolator.assemblyInterpolator(interpolator, is, getLogger());
        final AssemblyXpp3Reader r = new AssemblyXpp3Reader(transformer);
        assembly = r.read(reader);
        ComponentXpp3Reader.ContentTransformer ctrans = AssemblyInterpolator.componentInterpolator(interpolator, is, getLogger());
        mergeComponentsWithMainAssembly(assembly, assemblyDir, configSource, ctrans);
        debugPrintAssembly("After assembly is interpolated:", assembly);
        AssemblyInterpolator.checkErrors(AssemblyId.createAssemblyId(assembly), is, getLogger());
        reader.close();
        reader = null;
    } catch (final IOException e) {
        throw new AssemblyReadException("Error reading descriptor: " + locationDescription + ": " + e.getMessage(), e);
    } catch (final XmlPullParserException e) {
        throw new AssemblyReadException("Error reading descriptor: " + locationDescription + ": " + e.getMessage(), e);
    } finally {
        IOUtil.close(reader);
    }
    if (assembly.isIncludeSiteDirectory()) {
        includeSiteInAssembly(assembly, configSource);
    }
    return assembly;
}
Also used : FixedStringSearchInterpolator(org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator) AssemblyXpp3Reader(org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Reader) IOException(java.io.IOException) MavenProject(org.apache.maven.project.MavenProject) ComponentXpp3Reader(org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Reader) PrefixAwareRecursionInterceptor(org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor) RecursionInterceptor(org.codehaus.plexus.interpolation.RecursionInterceptor) InterpolationState(org.codehaus.plexus.interpolation.fixed.InterpolationState) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) PrefixAwareRecursionInterceptor(org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 2 with RecursionInterceptor

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

the class AbstractKojiIT method initTestConfig.

@Override
protected void initTestConfig(CoreServerFixture fixture) throws IOException {
    super.initTestConfig(fixture);
    withNewClient((client) -> {
        try {
            File clientKeyCertPem = getClientKeyCertPem(client);
            File serverCertsPem = getServerCertsPem(client);
            Properties properties = System.getProperties();
            properties.setProperty("client.pem", clientKeyCertPem.getAbsolutePath());
            properties.setProperty("server.pem", serverCertsPem.getAbsolutePath());
            properties.setProperty("hub.url", formatSSLUrl("kojihub"));
            properties.setProperty("storage.url", formatSSLUrl("kojifiles"));
            properties.setProperty("extra.config", getKojiExtraConfig());
            StringSearchInterpolator ssi = new StringSearchInterpolator();
            ssi.addValueSource(new PropertiesBasedValueSource(properties));
            RecursionInterceptor ri = new SimpleRecursionInterceptor();
            String kojiConf = readTestResource("test-koji.conf");
            try {
                kojiConf = ssi.interpolate(kojiConf, ri);
            } catch (InterpolationException e) {
                e.printStackTrace();
                fail("Interpolation of test koji.conf failed!");
            }
            writeConfigFile("conf.d/koji.conf", kojiConf);
        } catch (IOException e) {
            e.printStackTrace();
            fail("Cannot setup SSL config files for Koji.");
        }
    });
}
Also used : StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) SimpleRecursionInterceptor(org.codehaus.plexus.interpolation.SimpleRecursionInterceptor) RecursionInterceptor(org.codehaus.plexus.interpolation.RecursionInterceptor) SimpleRecursionInterceptor(org.codehaus.plexus.interpolation.SimpleRecursionInterceptor) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.PropertiesBasedValueSource)

Aggregations

IOException (java.io.IOException)2 RecursionInterceptor (org.codehaus.plexus.interpolation.RecursionInterceptor)2 File (java.io.File)1 Properties (java.util.Properties)1 Assembly (org.apache.maven.plugins.assembly.model.Assembly)1 AssemblyXpp3Reader (org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Reader)1 ComponentXpp3Reader (org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Reader)1 MavenProject (org.apache.maven.project.MavenProject)1 InterpolationException (org.codehaus.plexus.interpolation.InterpolationException)1 PrefixAwareRecursionInterceptor (org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor)1 PropertiesBasedValueSource (org.codehaus.plexus.interpolation.PropertiesBasedValueSource)1 SimpleRecursionInterceptor (org.codehaus.plexus.interpolation.SimpleRecursionInterceptor)1 StringSearchInterpolator (org.codehaus.plexus.interpolation.StringSearchInterpolator)1 FixedStringSearchInterpolator (org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator)1 InterpolationState (org.codehaus.plexus.interpolation.fixed.InterpolationState)1 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)1