Java Code Examples for org.codehaus.plexus.util.IOUtil#close()

The following examples show how to use org.codehaus.plexus.util.IOUtil#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuxPropsImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private FileObject copyToCacheDir(InputStream in) throws IOException {
    FileObject cacheDir = cacheDir();
    FileObject file = cacheDir.getFileObject("checkstyle-checker.xml");
    if (file == null) {
        file = cacheDir.createData("checkstyle-checker", "xml");
    }
    InputStream inst = in;
    OutputStream outst = null;
    try {
        outst = file.getOutputStream();
        FileUtil.copy(in, outst);
    } finally {
        IOUtil.close(inst);
        IOUtil.close(outst);
    }
    return file;
}
 
Example 2
Source File: CapsuleMojo.java    From capsule-maven-plugin with MIT License 6 votes vote down vote up
private File createExecCopyProcess(final File jar, final String prefix, final String extension) throws IOException {
	final File x = new File(jar.getPath().replace(".jar", extension));
	if (x.exists()) {
		debug("EXISTS - " + x.getName());
		return x;
	}

	FileOutputStream out = null;
	FileInputStream in = null;
	try {
		out = new FileOutputStream(x);
		in = new FileInputStream(jar);
		out.write((prefix).getBytes("ASCII"));
		Files.copy(jar.toPath(), out);
		out.flush();
		//			Runtime.getRuntime().exec("chmod +x " + x.getAbsolutePath());
		final boolean execResult = x.setExecutable(true, false);
		if (!execResult)
			warn("Failed to mark file executable - " + x.getAbsolutePath());
	} finally {
		IOUtil.close(in);
		IOUtil.close(out);
	}
	return x;
}
 
Example 3
Source File: PersistentVersionSelector.java    From pomutils with Apache License 2.0 6 votes vote down vote up
/**
 * Writes the selection state to {@link #persistentFile}.
 */
private void writeState(SelectionState selectionState) throws IOException {
	FileWriter writer = null; 
	
	try {
		writer = new FileWriter(persistentFile);
		Properties properties = selectionState.toProperties();
		properties.store(
				writer,
				String.format("Used by the 'pomutils' merge driver to store version selections%n"
					+ "within the same invocation of git merge%n"
					+ "(to avoid repeatedly prompting the user to select a version).%n"
					+ "Selected versions will only be reused for 2 minutes.%n"
					+ "It is safe to delete this file between git merge invocations%n"
					+ "(which will cause the user to be prompted again).%n"));
	} finally {
		IOUtil.close(writer);
	}
}
 
Example 4
Source File: AbstractDaemonGeneratorTest.java    From appassembler with MIT License 6 votes vote down vote up
private static String getAppAssemblerBooterVersion()
    throws IOException, XmlPullParserException
{
    if ( appassemblerVersion == null )
    {
        MavenXpp3Reader reader = new MavenXpp3Reader();
        FileReader fileReader = new FileReader( getTestFile( "pom.xml" ) );
        try
        {
            appassemblerVersion = reader.read( fileReader ).getParent().getVersion();
        }
        finally
        {
            IOUtil.close( fileReader );
        }
    }
    return appassemblerVersion;
}
 
Example 5
Source File: PersistentVersionSelector.java    From pomutils with Apache License 2.0 6 votes vote down vote up
/**
 * Reads the selection state from {@link #persistentFile}.
 */
private SelectionState readState() throws IOException {
	if (!persistentFile.canRead()) {
		return null;
	}
	
	if (persistentFile.lastModified() < System.currentTimeMillis() - TIMEOUT) {
		return null;
	}
	
	FileReader reader = null; 
	
	try {
		reader = new FileReader(persistentFile);
		Properties properties = new Properties();
		properties.load(reader);
		
		return SelectionState.fromProperties(properties);
	} finally {
		IOUtil.close(reader);
	}
}
 
Example 6
Source File: ExecMojo.java    From exec-maven-plugin with Apache License 2.0 6 votes vote down vote up
private void createArgFile( String filePath, List<String> lines )
    throws IOException
{
    final String EOL = System.getProperty( "line.separator", "\\n" );

    FileWriter writer = null;
    try
    {
        writer = new FileWriter( filePath );
        for ( String line : lines )
        {
            writer.append( line ).append( EOL );
        }

    }
    finally
    {
        IOUtil.close( writer );
    }
}
 
Example 7
Source File: MavenWhiteListQueryImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Manifest getManifest(FileObject root) {
    FileObject manifestFo = root.getFileObject("META-INF/MANIFEST.MF");
    if (manifestFo != null) {
        InputStream is = null;
        try {
            is = manifestFo.getInputStream();
            return new Manifest(is);
        } catch (IOException ex) {
            //Exceptions.printStackTrace(ex);
        } finally {
            IOUtil.close(is);
        }
    }
    return null;

}
 
Example 8
Source File: Mojo.java    From capsule-maven-plugin with MIT License 5 votes vote down vote up
JarOutputStream addToJar(final String name, final InputStream input, final JarOutputStream jar) throws IOException {
	try {
		debug("\t[Added to Jar]: " + name);
		jar.putNextEntry(new ZipEntry(name));
		IOUtil.copy(input, jar);
		jar.closeEntry();
	} catch (final ZipException ignore) {} // ignore duplicate entries and other errors
	IOUtil.close(input);
	return jar;
}
 
Example 9
Source File: AbstractVersionsUpdaterMojo.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Writes a StringBuilder into a file.
 *
 * @param outFile The file to read.
 * @param input The contents of the file.
 * @throws IOException when things go wrong.
 */
protected final void writeFile( File outFile, StringBuilder input )
    throws IOException
{
    Writer writer = WriterFactory.newXmlWriter( outFile );
    try
    {
        IOUtil.copy( input.toString(), writer );
    }
    finally
    {
        IOUtil.close( writer );
    }
}
 
Example 10
Source File: AbstractDaemonGeneratorTest.java    From appassembler with MIT License 5 votes vote down vote up
protected File createFilteredFile( String file )
    throws IOException, FileNotFoundException, DaemonGeneratorException, XmlPullParserException
{
    String version = getAppAssemblerBooterVersion();
    Properties context = new Properties();
    context.setProperty( "appassembler.version", version );

    File tempPom = File.createTempFile( "appassembler", "tmp" );
    tempPom.deleteOnExit();

    InterpolationFilterReader reader =
        new InterpolationFilterReader( new FileReader( getTestFile( file ) ), context, "@", "@" );
    FileWriter out = null;

    try
    {
        out = new FileWriter( tempPom );

        IOUtil.copy( reader, out );
    }
    catch ( IOException e )
    {
        throw new DaemonGeneratorException( "Error writing output file: " + tempPom.getAbsolutePath(), e );
    }
    finally
    {
        IOUtil.close( reader );
        IOUtil.close( out );
    }
    return tempPom;
}
 
Example 11
Source File: SimpleNamespaceResolver.java    From jaxb2-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new SimpleNamespaceResolver which collects namespace data
 * from the provided XML file.
 *
 * @param xmlFile The XML file from which to collect namespace data, should not be null.
 */
public SimpleNamespaceResolver(final File xmlFile) {
    this.sourceFilename = xmlFile.getName();

    Reader reader = null;
    try {
        reader = new FileReader(xmlFile);
        initialize(reader);
    } catch (FileNotFoundException e) {
        throw new IllegalArgumentException("File [" + xmlFile + "] could not be found.");
    } finally {
        IOUtil.close(reader);
    }
}
 
Example 12
Source File: XsdGeneratorHelper.java    From jaxb2-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a Document from parsing the XML within the provided xmlFile.
 *
 * @param xmlFile The XML file to be parsed.
 * @return The Document corresponding to the xmlFile.
 */
private static Document parseXmlToDocument(final File xmlFile) {
    Document result = null;
    Reader reader = null;
    try {
        reader = new FileReader(xmlFile);
        result = parseXmlStream(reader);
    } catch (FileNotFoundException e) {
        // This should never happen...
    } finally {
        IOUtil.close(reader);
    }

    return result;
}
 
Example 13
Source File: RawXJC2Mojo.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addIfExistsToEpisodeSchemaBindings() throws MojoExecutionException {
	if (!getEpisode() || !isAddIfExistsToEpisodeSchemaBindings()) {
		return;
	}
	final File episodeFile = getEpisodeFile();
	if (!episodeFile.canWrite()) {
		getLog().warn(MessageFormat
				.format("Episode file [{0}] is not writable, could not add if-exists attributes.", episodeFile));
		return;
	}
	InputStream is = null;
	try {
		final TransformerFactory transformerFactory = TransformerFactory.newInstance();
		is = getClass().getResourceAsStream(ADD_IF_EXISTS_TO_EPISODE_SCHEMA_BINDINGS_TRANSFORMATION_RESOURCE_NAME);
		final Transformer addIfExistsToEpisodeSchemaBindingsTransformer = transformerFactory
				.newTransformer(new StreamSource(is));
		final DOMResult result = new DOMResult();
		addIfExistsToEpisodeSchemaBindingsTransformer.transform(new StreamSource(episodeFile), result);
		final DOMSource source = new DOMSource(result.getNode());
		final Transformer identityTransformer = transformerFactory.newTransformer();
		identityTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
		identityTransformer.transform(source, new StreamResult(episodeFile));
		getLog().info(MessageFormat.format("Episode file [{0}] was augmented with if-exists=\"true\" attributes.",
				episodeFile));
	} catch (TransformerException e) {
		throw new MojoExecutionException(MessageFormat.format(
				"Error augmenting the episode file [{0}] with if-exists=\"true\" attributes. Transformation failed with an unexpected error.",
				episodeFile), e);
	} finally {
		IOUtil.close(is);
	}
}
 
Example 14
Source File: MavenNbModuleImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Xpp3Dom getModuleDom() throws UnsupportedEncodingException, IOException, XmlPullParserException {
    //TODO convert to FileOBject and have the IO stream from there..
    File file = getModuleXmlLocation();
    if (!file.exists()) {
        return null;
    }
    FileInputStream is = new FileInputStream(file);
    Reader reader = new InputStreamReader(is, "UTF-8"); //NOI18N
    try {
        return Xpp3DomBuilder.build(reader);
    } finally {
        IOUtil.close(reader);
    }
}
 
Example 15
Source File: JavaServiceWrapperDaemonGenerator.java    From appassembler with MIT License 4 votes vote down vote up
private void writeWrapperConfFile( DaemonGenerationRequest request, Daemon daemon, File outputDirectory,
                                   Properties context, Properties configuration )
                                       throws DaemonGeneratorException
{
    InputStream in = this.getClass().getResourceAsStream( "conf/wrapper.conf.in" );

    if ( in == null )
    {
        throw new DaemonGeneratorException( "Could not load template." );
    }

    FormattedProperties confFile = new FormattedProperties();

    try
    {
        confFile.read( in );
    }
    catch ( IOException e )
    {
        throw new DaemonGeneratorException( "Error reading template: " + e.getMessage(), e );
    }
    finally
    {
        IOUtil.close( in );
    }

    // TODO: configurable?
    confFile.setPropertyAfter( "wrapper.working.dir", "..", "wrapper.java.command" );
    confFile.setProperty( "wrapper.java.library.path.1", daemon.getRepositoryName() );
    confFile.setPropertyAfter( "set.default.REPO_DIR", daemon.getRepositoryName(), "wrapper.java.mainclass" );

    confFile.setPropertyAfter( "set." + context.getProperty( "app.base.envvar" ), ".", "wrapper.java.mainclass" );

    if ( daemon.getWrapperLogFile() == null )
    {
        // Write the default value to the wrapper.logfile.
        confFile.setProperty( "wrapper.logfile", "../logs/wrapper.log" );
    }
    else
    {
        confFile.setProperty( "wrapper.logfile", daemon.getWrapperLogFile() );
    }

    if ( daemon.getJvmSettings() != null && !StringUtils.isEmpty( daemon.getJvmSettings().getInitialMemorySize() ) )
    {
        confFile.setProperty( "wrapper.java.initmemory", daemon.getJvmSettings().getInitialMemorySize() );
    }

    if ( daemon.getJvmSettings() != null && !StringUtils.isEmpty( daemon.getJvmSettings().getMaxMemorySize() ) )
    {
        confFile.setProperty( "wrapper.java.maxmemory", daemon.getJvmSettings().getMaxMemorySize() );
    }

    confFile.setProperty( "wrapper.java.mainclass", daemon.getWrapperMainClass() );
    if ( !StringUtils.isEmpty( daemon.getMainClass() ) )
    {
        confFile.setProperty( "wrapper.app.parameter.1", daemon.getMainClass() );
    }

    createClasspath( daemon, request, confFile, configuration );
    createAdditional( daemon, confFile );
    createParameters( daemon, confFile );

    for ( Map.Entry entry : configuration.entrySet() )
    {
        String key = (String) entry.getKey();
        String value = (String) entry.getValue();
        if ( value.length() > 0 )
        {
            confFile.setProperty( key, value );
        }
        else
        {
            confFile.removeProperty( key );
        }
    }

    ByteArrayOutputStream string = new ByteArrayOutputStream();
    confFile.save( string );

    Reader reader = new InputStreamReader( new ByteArrayInputStream( string.toByteArray() ) );

    File wrapperConf =
        new File( outputDirectory, daemon.getConfigurationDirectory() + "/" + getWrapperConfigFileName( daemon ) );
    writeFilteredFile( request, daemon, reader, wrapperConf, context );

    if ( daemon.getPreWrapperConf() != null )
    {
        insertPreWrapperConf( wrapperConf, new File( daemon.getPreWrapperConf() ) );
    }

}
 
Example 16
Source File: ExecMojo.java    From tomee with Apache License 2.0 4 votes vote down vote up
private void createExecutableJar() throws Exception {
    mkdirs(execFile.getParentFile());

    final Properties config = new Properties();
    config.put("distribution", distributionName);
    config.put("workingDir", runtimeWorkingDir);
    config.put("command", DEFAULT_SCRIPT.equals(script) ? (skipArchiveRootFolder ? "" : catalinaBase.getName() + "/") + DEFAULT_SCRIPT : script);
    final List<String> jvmArgs = generateJVMArgs();

    final String catalinaOpts = toString(jvmArgs, " ");
    config.put("catalinaOpts", catalinaOpts);
    config.put("timestamp", Long.toString(System.currentTimeMillis()));
    // java only
    final String cp = getAdditionalClasspath();
    if (cp != null) {
        config.put("additionalClasspath", cp);
    }
    config.put("shutdownCommand", tomeeShutdownCommand);
    int i = 0;
    boolean encodingSet = catalinaOpts.contains("-Dfile.encoding");
    for (final String jvmArg : jvmArgs) {
        config.put("jvmArg." + i++, jvmArg);
        encodingSet = encodingSet || jvmArg.contains("-Dfile.encoding");
    }
    if (!encodingSet) { // forcing encoding for launched process to be able to read conf files
        config.put("jvmArg." + i, "-Dfile.encoding=UTF-8");
    }

    if (preTasks != null) {
        config.put("preTasks", toString(preTasks, ","));
    }
    if (postTasks != null) {
        config.put("postTasks", toString(postTasks, ","));
    }
    config.put("waitFor", Boolean.toString(waitFor));

    // create an executable jar with main runner and zipFile
    final FileOutputStream fileOutputStream = new FileOutputStream(execFile);
    final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.JAR, fileOutputStream);

    { // distrib
        os.putArchiveEntry(new JarArchiveEntry(distributionName));
        final FileInputStream in = new FileInputStream(zipFile);
        try {
            IOUtils.copy(in, os);
            os.closeArchiveEntry();
        } finally {
            IOUtil.close(in);
        }
    }

    { // config
        os.putArchiveEntry(new JarArchiveEntry("configuration.properties"));
        final StringWriter writer = new StringWriter();
        config.store(writer, "");
        IOUtils.copy(new ByteArrayInputStream(writer.toString().getBytes("UTF-8")), os);
        os.closeArchiveEntry();
    }

    { // Manifest
        final Manifest manifest = new Manifest();

        final Manifest.Attribute mainClassAtt = new Manifest.Attribute();
        mainClassAtt.setName("Main-Class");
        mainClassAtt.setValue(runnerClass);
        manifest.addConfiguredAttribute(mainClassAtt);

        final ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
        manifest.write(baos);

        os.putArchiveEntry(new JarArchiveEntry("META-INF/MANIFEST.MF"));
        IOUtils.copy(new ByteArrayInputStream(baos.toByteArray()), os);
        os.closeArchiveEntry();
    }

    { // Main + utility
        for (final Class<?> clazz : asList(
                ExecRunner.class,
                Files.class, Files.PatternFileFilter.class, Files.DeleteThread.class,
                Files.FileRuntimeException.class, Files.FileDoesNotExistException.class, Files.NoopOutputStream.class,
                LoaderRuntimeException.class,
                Pipe.class, IO.class, Zips.class, JarLocation.class,
                RemoteServer.class, RemoteServer.CleanUpThread.class,
                OpenEJBRuntimeException.class, Join.class, QuickServerXmlParser.class,
                Options.class, Options.NullLog.class, Options.TomEEPropertyAdapter.class, Options.NullOptions.class,
                Options.Log.class, JavaSecurityManagers.class)) {
            addToJar(os, clazz);
        }
    }
    addClasses(additionalClasses, os);
    addClasses(preTasks, os);
    addClasses(postTasks, os);

    IOUtil.close(os);
    IOUtil.close(fileOutputStream);
}
 
Example 17
Source File: FormattedProperties.java    From appassembler with MIT License 4 votes vote down vote up
/**
 * Read in the properties from the given stream. Note that this will be used as the basis of the next formatted
 * write, even though properties from any previous read are still retained. This allows adding properties to the top
 * of the file.
 *
 * @param inputStream the stream to read from
 * @throws IOException if there is a problem reading the stream
 */
public void read( InputStream inputStream )
    throws IOException
{
    synchronized ( properties )
    {
        fileLines = new ArrayList<String>();
        propertyLines = new HashMap<String, Integer>();

        BufferedReader r = new BufferedReader( new InputStreamReader( inputStream, "UTF-8") );

        try
        {
            int lineNo = 1;
            String line = r.readLine();
            while ( line != null )
            {
                // parse the key and value. No = means it's not a property, multiple = will be attributed to the
                // value
                String[] pair = line.split( "=", 2 );
                String key = pair[0];
                String value;
                if ( pair.length > 1 )
                {
                    value = pair[1].trim();

                    // is the line a comment?
                    boolean commented = false;
                    if ( key.startsWith( "#" ) )
                    {
                        commented = true;
                        key = key.substring( 1 );
                    }

                    key = key.trim();

                    // if it's not commented, set the property
                    if ( !commented )
                    {
                        // must use our setProperty to update list properties too
                        setProperty( key, value );
                    }

                    // regardless of whether it's a comment, track the key it might have been (only the base key if
                    // it's a list) so we know where to add any new properties later
                    Matcher m = LIST_KEY_PATTERN.matcher( key );
                    if ( m.matches() )
                    {
                        key = m.group( 1 );
                    }

                    propertyLines.put( key, new Integer( lineNo ) );
                }

                fileLines.add( line );

                line = r.readLine();
                lineNo++;
            }
        }
        finally
        {
            IOUtil.close( r );
        }
    }
}
 
Example 18
Source File: CapsuleMojo.java    From capsule-maven-plugin with MIT License 4 votes vote down vote up
/**
 * Build the capsule jar based on the parameters
 */
public void build() throws IOException {
	final File jarFile = new File(this.outputDir, this.outputName + ".jar");

	if (jarFile.exists()) {
		info("EXISTS - " + jarFile.getName() + " (WILL OVERWRITE)");
		final boolean deleteResult = jarFile.delete();
		if (!deleteResult) {
			warn("FAILED TO DELETE - " + jarFile.getName());
		}
	}

	final JarOutputStream jarStream = new JarOutputStream(new FileOutputStream(jarFile));
	info("[Capsule Jar File]: " + jarFile.getName());

	// add manifest entries
	addManifest(jarStream);

	// add Capsule.class
	addCapsuleClass(jarStream);

	// add caplets - i.e custom capsule classes (if exists)
	addCapletClasses(jarStream);

	// add CapsuleMaven classes (if we need to do any resolving on launch)
	addMavenCapletClasses(jarStream);

	// add the app jar
	addApp(jarStream);

	// add the dependencies as embedded jars
	addDependencies(jarStream);

	// add some files and folders to the capsule from filesets and dependencysets
	addFileSets(jarStream);
	addDependencySets(jarStream);

	IOUtil.close(jarStream);

	// build the chmod version of the capsule
	addChmodCopy(jarFile);

	// build the trampoline version of the capsule
	addTrampolineCopy(jarFile);

	// attach the capsule as a maven artifact
	info("[Maven Artifact]: Attached capsule artifact to maven (" + jarFile.getName() + ").");
	helper.attachArtifact(project, jarFile, "capsule");
}
 
Example 19
Source File: ExternalVersionExtension.java    From maven-external-version with Apache License 2.0 4 votes vote down vote up
private void createNewVersionPom( MavenProject mavenProject, Map<String, String> gavVersionMap )
    throws IOException, XmlPullParserException
{
    Reader fileReader = null;
    Writer fileWriter = null;
    try
    {
        fileReader = new FileReader( mavenProject.getFile() );
        Model model = new MavenXpp3Reader().read( fileReader );
        model.setVersion( mavenProject.getVersion() );


        // TODO: this needs to be restructured when other references are updated (dependencies, dep-management, plugins, etc)
        if ( model.getParent() != null )
        {
            String key = buildGavKey( model.getParent().getGroupId(), model.getParent().getArtifactId(),
                                      model.getParent().getVersion() );
            String newVersionForParent = gavVersionMap.get( key );
            if ( newVersionForParent != null )
            {
                model.getParent().setVersion( newVersionForParent );
            }
        }
        
        Plugin plugin = mavenProject.getPlugin( "org.apache.maven.plugins:maven-external-version-plugin" );
        // now we are going to wedge in the config
        Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration();
        
        File newPom = createFileFromConfiguration( mavenProject, pluginConfiguration ); 
        logger.debug( ExternalVersionExtension.class.getSimpleName() + ": using new pom file => " + newPom );
        fileWriter = new FileWriter( newPom );
        new MavenXpp3Writer().write( fileWriter, model );

        mavenProject.setFile( newPom );
    }
    finally
    {
        IOUtil.close( fileReader );
        IOUtil.close( fileWriter );
    }


}
 
Example 20
Source File: DoxiaSiteRenderer.java    From helidon-build-tools with Apache License 2.0 4 votes vote down vote up
@Override
public void render(Collection<DocumentRenderer> documents, SiteRenderingContext context, File outputDirectory)
        throws RendererException, IOException {

    for (DocumentRenderer docRenderer : documents) {
        if (!(docRenderer instanceof ReportDocumentRenderer)) {
            continue;
        }
        RenderingContext renderingContext = docRenderer.getRenderingContext();
        File outputFile = new File(outputDirectory, docRenderer.getOutputName());
        File inputFile = new File(renderingContext.getBasedir(), renderingContext.getInputName());
        boolean modified = !outputFile.exists()
                || (inputFile.lastModified() > outputFile.lastModified())
                || (context.getDecoration().getLastModified() > outputFile.lastModified());

        if (modified || docRenderer.isOverwrite()) {
            if (!outputFile.getParentFile().exists()) {
                outputFile.getParentFile().mkdirs();
            }

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Generating " + outputFile);
            }

            Writer writer = null;
            try {
                if (!docRenderer.isExternalReport()) {
                    writer = WriterFactory.newWriter(outputFile, context.getOutputEncoding());
                }
                docRenderer.renderDocument(writer, this, context);
            } finally {
                IOUtil.close(writer);
            }
        } else {
            if (getLogger().isDebugEnabled()) {
                getLogger().debug(inputFile + " unchanged, not regenerating...");
            }
        }
    }

    Properties properties = new Properties();
    Map<String, ?> templateProps = context.getTemplateProperties();
    if (templateProps != null) {
        properties.putAll(templateProps);
        MavenProject project = (MavenProject) templateProps.get("project");
        if (project != null) {
            properties.setProperty("project.groupId", project.getGroupId());
            properties.setProperty("project.artifactId", project.getArtifactId());
            properties.setProperty("project.version", project.getVersion());
            properties.setProperty("project.basedir", project.getBasedir().getAbsolutePath());
        }
    }

    File siteDirectory = context.getSiteDirectories().iterator().next();
    File siteConfigFile = new File(siteDirectory, "sitegen.yaml");
    Site site = Site.builder()
            .config(siteConfigFile, properties)
            .build();

    // enable jruby verbose mode on debugging
    if (getLogger().isDebugEnabled()) {
        System.setProperty("jruby.cli.verbose", "true");
    }

    try {
        site.generate(siteDirectory, outputDirectory);
    } catch (RenderingException ex) {
        throw new RendererException(ex.getMessage(), ex);
    }
}