a30a58d36c493010e4968550535a3f0208df005fviolette * CDDL HEADER START
a30a58d36c493010e4968550535a3f0208df005fviolette * The contents of this file are subject to the terms of the
a30a58d36c493010e4968550535a3f0208df005fviolette * Common Development and Distribution License, Version 1.0 only
a30a58d36c493010e4968550535a3f0208df005fviolette * (the "License"). You may not use this file except in compliance
a30a58d36c493010e4968550535a3f0208df005fviolette * with the License.
a30a58d36c493010e4968550535a3f0208df005fviolette * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
a30a58d36c493010e4968550535a3f0208df005fviolette * See the License for the specific language governing permissions
a30a58d36c493010e4968550535a3f0208df005fviolette * and limitations under the License.
a30a58d36c493010e4968550535a3f0208df005fviolette * When distributing Covered Code, include this CDDL HEADER in each
a30a58d36c493010e4968550535a3f0208df005fviolette * file and include the License file at legal-notices/CDDLv1_0.txt.
a30a58d36c493010e4968550535a3f0208df005fviolette * If applicable, add the following below this CDDL HEADER, with the
a30a58d36c493010e4968550535a3f0208df005fviolette * fields enclosed by brackets "[]" replaced with your own identifying
a30a58d36c493010e4968550535a3f0208df005fviolette * information:
a30a58d36c493010e4968550535a3f0208df005fviolette * Portions Copyright [yyyy] [name of copyright owner]
a30a58d36c493010e4968550535a3f0208df005fviolette * CDDL HEADER END
a30a58d36c493010e4968550535a3f0208df005fviolette * Copyright 2013 ForgeRock AS
a30a58d36c493010e4968550535a3f0208df005fviolette * A utility class for the packaging process. It is used by the build.xml to
a30a58d36c493010e4968550535a3f0208df005fviolette * perform the package construction.
a30a58d36c493010e4968550535a3f0208df005fviolette /** The source directory name */
a30a58d36c493010e4968550535a3f0208df005fviolette /** Files contained in the package */
a30a58d36c493010e4968550535a3f0208df005fviolette private final List<File> files = new LinkedList<File>();
a30a58d36c493010e4968550535a3f0208df005fviolette /** Files which should be excluded from the package */
a30a58d36c493010e4968550535a3f0208df005fviolette private final List<File> excludedFiles = new LinkedList<File>();
a30a58d36c493010e4968550535a3f0208df005fviolette /** Package documentation files */
a30a58d36c493010e4968550535a3f0208df005fviolette private final List<File> docFiles = new LinkedList<File>();
a30a58d36c493010e4968550535a3f0208df005fviolette /** The end-of-line character for this platform */
a30a58d36c493010e4968550535a3f0208df005fviolette private static String EOL = System.getProperty("line.separator");
a30a58d36c493010e4968550535a3f0208df005fviolette * Returns the source directory name.
a30a58d36c493010e4968550535a3f0208df005fviolette * @return The source directory name.
a30a58d36c493010e4968550535a3f0208df005fviolette * Sets the source directory name.
a30a58d36c493010e4968550535a3f0208df005fviolette * @param sourceDirName
a30a58d36c493010e4968550535a3f0208df005fviolette * The source directory name.
a30a58d36c493010e4968550535a3f0208df005fviolette // Process the filtering of the files contained in the given directory.
a30a58d36c493010e4968550535a3f0208df005fviolette // Sorts the list.
a30a58d36c493010e4968550535a3f0208df005fviolette // Returns the properties which can be used fill data.
a30a58d36c493010e4968550535a3f0208df005fviolette getProject().setNewProperty("listRPMFiles", formatAsFileList(files));
f0b6cf809372fb29ae063b49359fd18c8b425830violette getProject().setNewProperty("installRpmFiles", getInstallationFiles());
a30a58d36c493010e4968550535a3f0208df005fviolette "An error occurs during filtering package files", e);
f0b6cf809372fb29ae063b49359fd18c8b425830violette * Returns the installation files for the RPM package.
f0b6cf809372fb29ae063b49359fd18c8b425830violette * @return A string containing the installation files for the RPM package.
f0b6cf809372fb29ae063b49359fd18c8b425830violette return new StringBuilder("cp -rf \"").append(sourceDirName).append("\"/* .")
a30a58d36c493010e4968550535a3f0208df005fviolette * Formats the file list to be supported by RPM.
a30a58d36c493010e4968550535a3f0208df005fviolette * @param fileList
a30a58d36c493010e4968550535a3f0208df005fviolette * The list of files to be processed.
a30a58d36c493010e4968550535a3f0208df005fviolette * @return A string containing the list of files which should be excluded in
a30a58d36c493010e4968550535a3f0208df005fviolette * the RPM source.
a30a58d36c493010e4968550535a3f0208df005fviolette private String formatAsExcludedList(final List<File> fileList)
a30a58d36c493010e4968550535a3f0208df005fviolette * Formats the file list to be supported by RPM.
a30a58d36c493010e4968550535a3f0208df005fviolette * @param fileList
a30a58d36c493010e4968550535a3f0208df005fviolette * The list of files to be processed.
a30a58d36c493010e4968550535a3f0208df005fviolette * @return A string containing the list of files which can be included in the
a30a58d36c493010e4968550535a3f0208df005fviolette * RPM source.
a30a58d36c493010e4968550535a3f0208df005fviolette private String formatAsFileList(final List<File> fileList)
a30a58d36c493010e4968550535a3f0208df005fviolette * Formats the document list to be supported by RPM.
a30a58d36c493010e4968550535a3f0208df005fviolette * @param fileList
a30a58d36c493010e4968550535a3f0208df005fviolette * The list of files to be processed.
a30a58d36c493010e4968550535a3f0208df005fviolette * @return A string containing the formatted list doc.
a30a58d36c493010e4968550535a3f0208df005fviolette private String formatAsDocList(final List<File> fileList)
f0b6cf809372fb29ae063b49359fd18c8b425830violette // FIXME The folder needs to be copied as well.
a30a58d36c493010e4968550535a3f0208df005fviolette * Sorts all the files contained in selected directory and fills the
a30a58d36c493010e4968550535a3f0208df005fviolette * appropriate lists.
a30a58d36c493010e4968550535a3f0208df005fviolette * @param dir
a30a58d36c493010e4968550535a3f0208df005fviolette * The directory where to analyze the files.
a30a58d36c493010e4968550535a3f0208df005fviolette * @throws Exception
a30a58d36c493010e4968550535a3f0208df005fviolette * If an exception occurs during the process.
a30a58d36c493010e4968550535a3f0208df005fviolette private void filterFiles(final File dir) throws Exception
a30a58d36c493010e4968550535a3f0208df005fviolette final ExcludeFileFilter exFilter = new ExcludeFileFilter();
a30a58d36c493010e4968550535a3f0208df005fviolette final DocFileFilter docFilter = new DocFileFilter();
f0b6cf809372fb29ae063b49359fd18c8b425830violette // The spaces in path can generate errors. (see OPENDJ-1063)
a30a58d36c493010e4968550535a3f0208df005fviolette // Completes the excluded files list.
a30a58d36c493010e4968550535a3f0208df005fviolette // Completes the document file list.
a30a58d36c493010e4968550535a3f0208df005fviolette * Returns the relative path to given source directory name.
a30a58d36c493010e4968550535a3f0208df005fviolette * The file we want the relative path.
a30a58d36c493010e4968550535a3f0208df005fviolette * @return A string representing the relative path to the given source
a30a58d36c493010e4968550535a3f0208df005fviolette * directory name.
a30a58d36c493010e4968550535a3f0208df005fviolette return f.getAbsolutePath().replace(getSourceDirName(), "");
a30a58d36c493010e4968550535a3f0208df005fviolette * A file filter which excludes all files that belong to other OS.
a30a58d36c493010e4968550535a3f0208df005fviolette static final class ExcludeFileFilter implements FileFilter
a30a58d36c493010e4968550535a3f0208df005fviolette /** {@inheritDoc} */
a30a58d36c493010e4968550535a3f0208df005fviolette final String fileName = file.getName().toLowerCase();
a30a58d36c493010e4968550535a3f0208df005fviolette * A file filter which accepts only documentation files.
a30a58d36c493010e4968550535a3f0208df005fviolette static final class DocFileFilter implements FileFilter
a30a58d36c493010e4968550535a3f0208df005fviolette /** {@inheritDoc} */