private void attachConfigurations()

in src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java [89:152]


    private void attachConfigurations() throws MojoExecutionException, IOException, ArchiverException {
        if ( this.ignoreBundleListConfig ) {
            this.getLog().debug("ignoreBundleListConfig is set to true, therefore not attaching configurations.");
            return;
        }
        // check if we have configurations
        boolean hasConfigs = this.checkFile(this.getConfigDirectory());
        hasConfigs |= this.getSlingBootstrap(true) != null;
        hasConfigs |= this.getSlingBootstrap(false) != null;
        hasConfigs |= this.getSlingProperties(true) != null;
        hasConfigs |= this.getSlingProperties(false) != null;

        if ( !hasConfigs ) {
            this.getLog().debug("No configurations to attach.");
            return;
        }
        // copy configuration, as this project might use different names we have to copy everything!
        this.configOutputDir.mkdirs();
        if ( this.getSlingBootstrap(false) != null ) {
            final File slingDir = new File(this.configOutputDir, "sling");
            slingDir.mkdirs();
            FileUtils.fileWrite(new File(slingDir, AttachPartialBundleListMojo.SLING_WEBAPP_BOOTSTRAP).getAbsolutePath(),
                                "UTF-8", this.getSlingBootstrap(false));
        }
        if ( this.getSlingProperties(false) != null ) {
            final File slingDir = new File(this.configOutputDir, "sling");
            slingDir.mkdirs();
            final FileOutputStream fos = new FileOutputStream(new File(slingDir, AttachPartialBundleListMojo.SLING_WEBAPP_PROPS));
            try {
                this.getSlingProperties(false).store(fos, null);
            } finally {
                try { fos.close(); } catch (final IOException ioe) {}
            }
        }
        if ( this.getSlingBootstrap(true) != null ) {
            final File slingDir = new File(this.configOutputDir, "sling");
            slingDir.mkdirs();
            FileUtils.fileWrite(new File(slingDir, AttachPartialBundleListMojo.SLING_STANDALONE_BOOTSTRAP).getAbsolutePath(),
                    "UTF-8", this.getSlingBootstrap(true));
        }
        if ( this.getSlingProperties(true) != null ) {
            final File slingDir = new File(this.configOutputDir, "sling");
            slingDir.mkdirs();
            final FileOutputStream fos = new FileOutputStream(new File(slingDir, AttachPartialBundleListMojo.SLING_STANDALONE_PROPS));
            try {
                this.getSlingProperties(true).store(fos, null);
            } finally {
                try { fos.close(); } catch (final IOException ioe) {}
            }
        }
        if ( this.checkFile(this.getConfigDirectory()) ) {
            final File configDir = new File(this.configOutputDir, "config");
            configDir.mkdirs();
            copyDirectory(this.getConfigDirectory(), configDir,
                    null, FileUtils.getDefaultExcludes());
        }
        final File destFile = new File(this.configOutputDir.getParent(), this.configOutputDir.getName() + ".zip");
        zipArchiver.setDestFile(destFile);
        zipArchiver.addDirectory(this.configOutputDir);
        zipArchiver.createArchive();

        projectHelper.attachArtifact(project, AttachPartialBundleListMojo.CONFIG_TYPE,
                AttachPartialBundleListMojo.CONFIG_CLASSIFIER, destFile);
    }