From 3c066319dd9efbc24d0ab893fd4ddc6acd432a48 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sat, 8 Jan 2011 16:10:06 +0100 Subject: [PATCH 1/3] destroy session after logout --- .../java/sonia/scm/web/security/BasicSecurityContext.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scm-webapp/src/main/java/sonia/scm/web/security/BasicSecurityContext.java b/scm-webapp/src/main/java/sonia/scm/web/security/BasicSecurityContext.java index 86643ff23a..d53c04eec7 100644 --- a/scm-webapp/src/main/java/sonia/scm/web/security/BasicSecurityContext.java +++ b/scm-webapp/src/main/java/sonia/scm/web/security/BasicSecurityContext.java @@ -56,6 +56,7 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; /** * @@ -178,6 +179,13 @@ public class BasicSecurityContext implements WebSecurityContext { user = null; groups = new HashSet(); + + HttpSession session = request.getSession(false); + + if (session != null) + { + session.invalidate(); + } } //~--- get methods ---------------------------------------------------------- From d86bc762a58faf12cbd1ff49283d9e6d4b512b96 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 9 Jan 2011 18:34:31 +0100 Subject: [PATCH 2/3] create release profile --- scm-webapp/pom.xml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml index 576a45f938..a932e7ae0c 100644 --- a/scm-webapp/pom.xml +++ b/scm-webapp/pom.xml @@ -231,6 +231,49 @@ + + release + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + + ${project.build.directory}/web-compressor + + + + + + + + sonia.maven + web-compressor + 1.0-SNAPSHOT + + + prepare-package + + compress-template + + + + + src/main/webapp/index.html + ${project.build.directory}/web-compressor/index.html + false + + + + + + + development From 6d51912a1adb16a724e5e39d5edddedefb27258a Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 9 Jan 2011 18:35:28 +0100 Subject: [PATCH 3/3] move web-compressor to new repository (https://bitbucket.org/sdorra/maven-plugins) --- maven/pom.xml | 3 +- maven/scm-web-compressor/pom.xml | 52 --- .../scm/maven/AbstractWebCompressor.java | 267 --------------- .../sonia/scm/maven/ClosureWebCompressor.java | 169 ---------- .../java/sonia/scm/maven/WebCompressor.java | 75 ----- .../sonia/scm/maven/WebCompressorMojo.java | 311 ------------------ .../sonia/scm/maven/YuiWebCompressor.java | 159 --------- 7 files changed, 1 insertion(+), 1035 deletions(-) delete mode 100644 maven/scm-web-compressor/pom.xml delete mode 100644 maven/scm-web-compressor/src/main/java/sonia/scm/maven/AbstractWebCompressor.java delete mode 100644 maven/scm-web-compressor/src/main/java/sonia/scm/maven/ClosureWebCompressor.java delete mode 100644 maven/scm-web-compressor/src/main/java/sonia/scm/maven/WebCompressor.java delete mode 100644 maven/scm-web-compressor/src/main/java/sonia/scm/maven/WebCompressorMojo.java delete mode 100644 maven/scm-web-compressor/src/main/java/sonia/scm/maven/YuiWebCompressor.java diff --git a/maven/pom.xml b/maven/pom.xml index b2413a79cc..c402181075 100644 --- a/maven/pom.xml +++ b/maven/pom.xml @@ -16,7 +16,6 @@ scm-maven-plugins - scm-web-compressor scm-plugin-archetype @@ -30,4 +29,4 @@ - \ No newline at end of file + diff --git a/maven/scm-web-compressor/pom.xml b/maven/scm-web-compressor/pom.xml deleted file mode 100644 index 31b932a38c..0000000000 --- a/maven/scm-web-compressor/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - 4.0.0 - - - sonia.scm.maven - scm-maven-plugins - 1.0-M6-SNAPSHOT - - - sonia.scm.maven - scm-web-compressor - maven-plugin - 1.0-M6-SNAPSHOT - scm-web-compressor - - - - - sonia.scm - scm-core - 1.0-M6-SNAPSHOT - - - - org.apache.maven - maven-plugin-api - 2.2.1 - - - - org.jsoup - jsoup - 1.4.1 - - - - com.yahoo.platform.yui - yuicompressor - 2.4.2 - - - - com.google.closure - compiler - 20100917 - - - - - \ No newline at end of file diff --git a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/AbstractWebCompressor.java b/maven/scm-web-compressor/src/main/java/sonia/scm/maven/AbstractWebCompressor.java deleted file mode 100644 index 21fc05dfc6..0000000000 --- a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/AbstractWebCompressor.java +++ /dev/null @@ -1,267 +0,0 @@ -/** - * Copyright (c) 2010, Sebastian Sdorra - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of SCM-Manager; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.maven; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; - -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import sonia.scm.util.ChecksumUtil; -import sonia.scm.util.IOUtil; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -/** - * - * @author Sebastian Sdorra - */ -public abstract class AbstractWebCompressor implements WebCompressor -{ - - /** - * Method description - * - * - * @param document - * @param path - */ - protected abstract void appendElement(Document document, String path); - - /** - * Method description - * - * - * @param source - * @param target - * @param encoding - * - * @throws IOException - * @throws MojoExecutionException - * @throws MojoFailureException - */ - protected abstract void compress(File source, File target, String encoding) - throws IOException, MojoExecutionException, MojoFailureException; - - /** - * Method description - * - * - * @param document - * - * @return - */ - protected abstract Elements selectElements(Document document); - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - protected abstract String getExtension(); - - /** - * Method description - * - * - * @param inputDirectory - * @param element - * - * @return - */ - protected abstract File getFile(File inputDirectory, Element element); - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param document - * @param inputDirectory - * @param outputDirectory - * @param encoding - * @param outputPrefix - * @param concat - * - * @throws IOException - * @throws MojoExecutionException - * @throws MojoFailureException - */ - @Override - public void compress(Document document, File inputDirectory, - File outputDirectory, String encoding, - String outputPrefix, boolean concat) - throws IOException, MojoExecutionException, MojoFailureException - { - Elements elements = selectElements(document); - - if ((elements != null) &&!elements.isEmpty()) - { - if (concat) - { - File uncompressedFile = concat(elements, inputDirectory); - - compress(document, encoding, outputDirectory, outputPrefix, - uncompressedFile); - } - else - { - for (Element element : elements) - { - File uncompressedFile = getFile(inputDirectory, element); - - compress(document, encoding, outputDirectory, outputPrefix, - uncompressedFile); - } - } - } - } - - /** - * Method description - * - * - * @param source - * @param target - * - * @throws IOException - */ - private void append(File source, File target) throws IOException - { - FileInputStream input = null; - FileOutputStream output = null; - - try - { - input = new FileInputStream(source); - output = new FileOutputStream(target, true); - IOUtil.copy(input, output); - } - finally - { - IOUtil.close(input); - IOUtil.close(output); - } - } - - /** - * Method description - * - * - * @param document - * @param encoding - * @param outputDirectory - * @param outputPrefix - * @param uncompressedFile - * - * @throws IOException - * @throws MojoExecutionException - * @throws MojoFailureException - */ - private void compress(Document document, String encoding, - File outputDirectory, String outputPrefix, - File uncompressedFile) - throws IOException, MojoExecutionException, MojoFailureException - { - File compressedFile = File.createTempFile("scm-", ".compressed"); - - compress(uncompressedFile, compressedFile, encoding); - IOUtil.delete(uncompressedFile); - - String checksum = ChecksumUtil.createChecksum(compressedFile); - String name = checksum.concat(".").concat(getExtension()); - File scriptFile = new File(outputDirectory, name); - - compressedFile.renameTo(scriptFile); - - if (!scriptFile.exists()) - { - - // TODO copy and remove - throw new IOException("could not move ".concat(compressedFile.getPath())); - } - - StringBuilder path = new StringBuilder(outputPrefix); - - if (!outputPrefix.endsWith("/")) - { - path.append("/"); - } - - path.append(name); - appendElement(document, path.toString()); - } - - /** - * Method description - * - * - * @param elements - * @param inputDirectory - * - * @return - * - * @throws IOException - */ - private File concat(Elements elements, File inputDirectory) throws IOException - { - File tempFile = File.createTempFile("scm-", ".concat"); - - for (Element scriptEl : elements) - { - File file = getFile(inputDirectory, scriptEl); - - if (file.exists()) - { - append(file, tempFile); - scriptEl.remove(); - } - } - - return tempFile; - } -} diff --git a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/ClosureWebCompressor.java b/maven/scm-web-compressor/src/main/java/sonia/scm/maven/ClosureWebCompressor.java deleted file mode 100644 index 6f351df573..0000000000 --- a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/ClosureWebCompressor.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Copyright (c) 2010, Sebastian Sdorra - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of SCM-Manager; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.maven; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.javascript.jscomp.CompilerOptions; -import com.google.javascript.jscomp.JSSourceFile; -import com.google.javascript.jscomp.Result; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; - -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import sonia.scm.util.IOUtil; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; - -/** - * - * @author Sebastian Sdorra - */ -public class ClosureWebCompressor extends AbstractWebCompressor -{ - - /** Field description */ - public static final String EXTENSION = "js"; - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param document - * @param path - */ - @Override - protected void appendElement(Document document, String path) - { - document.head().appendElement("script").attr("type", - "text/javascript").attr("src", path); - } - - /** - * Method description - * - * - * @param sourceFile - * @param targetFile - * @param encoding - * - * @throws IOException - * @throws MojoExecutionException - * @throws MojoFailureException - */ - @Override - protected void compress(File sourceFile, File targetFile, String encoding) - throws IOException, MojoExecutionException, MojoFailureException - { - com.google.javascript.jscomp.Compiler compiler = - new com.google.javascript.jscomp.Compiler(); - CompilerOptions options = new CompilerOptions(); - final JSSourceFile extern = JSSourceFile.fromCode("externs.js", - "function alert(x) {}"); - JSSourceFile source = JSSourceFile.fromFile(sourceFile); - Result result = compiler.compile(extern, source, options); - - if (!result.success) - { - throw new MojoFailureException("compression failed"); - } - else - { - FileOutputStream output = null; - - try - { - output = new FileOutputStream(targetFile); - output.write(compiler.toSource().getBytes(encoding)); - } - finally - { - IOUtil.close(output); - } - } - } - - /** - * Method description - * - * - * @param document - * - * @return - */ - @Override - protected Elements selectElements(Document document) - { - return document.select("script[type=text/javascript][src]"); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @Override - protected String getExtension() - { - return EXTENSION; - } - - /** - * Method description - * - * - * @param inputDirectory - * @param element - * - * @return - */ - @Override - protected File getFile(File inputDirectory, Element element) - { - return new File(inputDirectory, element.attr("src")); - } -} diff --git a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/WebCompressor.java b/maven/scm-web-compressor/src/main/java/sonia/scm/maven/WebCompressor.java deleted file mode 100644 index 273d319a96..0000000000 --- a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/WebCompressor.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2010, Sebastian Sdorra - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of SCM-Manager; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.maven; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; - -import org.jsoup.nodes.Document; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.IOException; - -/** - * - * @author Sebastian Sdorra - */ -public interface WebCompressor -{ - - /** - * Method description - * - * - * - * @param document - * @param inputDirectory - * @param outputDirectory - * @param encoding - * @param outputPrefix - * @param concat - * - * @throws IOException - * @throws MojoExecutionException - * @throws MojoFailureException - */ - public void compress(Document document, File inputDirectory, - File outputDirectory, String encoding, - String outputPrefix, boolean concat) - throws IOException, MojoExecutionException, MojoFailureException; -} diff --git a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/WebCompressorMojo.java b/maven/scm-web-compressor/src/main/java/sonia/scm/maven/WebCompressorMojo.java deleted file mode 100644 index 8a9d6e2e11..0000000000 --- a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/WebCompressorMojo.java +++ /dev/null @@ -1,311 +0,0 @@ -/** - * Copyright (c) 2010, Sebastian Sdorra - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of SCM-Manager; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.maven; - -//~--- non-JDK imports -------------------------------------------------------- - -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; - -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; - -import sonia.scm.util.IOUtil; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * @goal compress - * @author Sebastian Sdorra - */ -public class WebCompressorMojo extends AbstractMojo -{ - - /** - * Constructs ... - * - */ - public WebCompressorMojo() - { - compressorSet = new LinkedHashSet(); - compressorSet.add(new YuiWebCompressor()); - compressorSet.add(new ClosureWebCompressor()); - } - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @throws MojoExecutionException - * @throws MojoFailureException - */ - @Override - public void execute() throws MojoExecutionException, MojoFailureException - { - IOUtil.mkdirs(outputDirectory); - - OutputStream output = null; - - try - { - Document document = Jsoup.parse(inputFile, encoding); - File inputDirectory = inputFile.getParentFile(); - - for (WebCompressor compressor : compressorSet) - { - compressor.compress(document, inputDirectory, outputDirectory, - encoding, outputPrefix, concat); - } - - IOUtil.mkdirs(outputFile.getParentFile()); - output = new FileOutputStream(outputFile); - output.write(document.html().getBytes(encoding)); - } - catch (IOException ex) - { - throw new MojoExecutionException(ex.getMessage(), ex); - } - finally - { - IOUtil.close(output); - } - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public Set getCompressorSet() - { - return compressorSet; - } - - /** - * Method description - * - * - * @return - */ - public String getEncoding() - { - return encoding; - } - - /** - * Method description - * - * - * @return - */ - public File getInputFile() - { - return inputFile; - } - - /** - * Method description - * - * - * @return - */ - public File getOutputDirectory() - { - return outputDirectory; - } - - /** - * Method description - * - * - * @return - */ - public File getOutputFile() - { - return outputFile; - } - - /** - * Method description - * - * - * @return - */ - public String getOutputPrefix() - { - return outputPrefix; - } - - /** - * Method description - * - * - * @return - */ - public boolean isConcat() - { - return concat; - } - - //~--- set methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param compressorSet - */ - public void setCompressorSet(Set compressorSet) - { - this.compressorSet = compressorSet; - } - - /** - * Method description - * - * - * @param concat - */ - public void setConcat(boolean concat) - { - this.concat = concat; - } - - /** - * Method description - * - * - * @param encoding - */ - public void setEncoding(String encoding) - { - this.encoding = encoding; - } - - /** - * Method description - * - * - * @param inputFile - */ - public void setInputFile(File inputFile) - { - this.inputFile = inputFile; - } - - /** - * Method description - * - * - * @param outputDirectory - */ - public void setOutputDirectory(File outputDirectory) - { - this.outputDirectory = outputDirectory; - } - - /** - * Method description - * - * - * @param outputFile - */ - public void setOutputFile(File outputFile) - { - this.outputFile = outputFile; - } - - /** - * Method description - * - * - * @param outputPrefix - */ - public void setOutputPrefix(String outputPrefix) - { - this.outputPrefix = outputPrefix; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private Set compressorSet; - - /** - * @parameter - */ - private String encoding = "UTF-8"; - - /** - * @parameter - */ - private boolean concat = true; - - /** - * @parameter - * @required - */ - private File inputFile; - - /** - * @parameter default-value="${project.build.directory}/web-compressor" - */ - private File outputDirectory; - - /** - * @parameter - * @required - */ - private File outputFile; - - /** - * @parameter - * @required - */ - private String outputPrefix; -} diff --git a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/YuiWebCompressor.java b/maven/scm-web-compressor/src/main/java/sonia/scm/maven/YuiWebCompressor.java deleted file mode 100644 index e7c25d97bc..0000000000 --- a/maven/scm-web-compressor/src/main/java/sonia/scm/maven/YuiWebCompressor.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright (c) 2010, Sebastian Sdorra - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of SCM-Manager; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.maven; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.yahoo.platform.yui.compressor.CssCompressor; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; - -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import sonia.scm.util.IOUtil; - -//~--- JDK imports ------------------------------------------------------------ - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; - -/** - * - * @author Sebastian Sdorra - */ -public class YuiWebCompressor extends AbstractWebCompressor -{ - - /** Field description */ - public static final String EXTENSION = "css"; - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param document - * @param path - */ - @Override - protected void appendElement(Document document, String path) - { - document.head().appendElement("link").attr("type", "text/css").attr("rel", - "stylesheet").attr("href", path); - } - - /** - * Method description - * - * - * @param source - * @param target - * @param encoding - * - * @throws IOException - * @throws MojoExecutionException - * @throws MojoFailureException - */ - @Override - protected void compress(File source, File target, String encoding) - throws IOException, MojoExecutionException, MojoFailureException - { - FileReader reader = null; - FileWriter writer = null; - - try - { - reader = new FileReader(source); - - CssCompressor compressor = new CssCompressor(reader); - - writer = new FileWriter(target); - compressor.compress(writer, 5000); - } - finally - { - IOUtil.close(reader); - IOUtil.close(writer); - } - } - - /** - * Method description - * - * - * @param document - * - * @return - */ - @Override - protected Elements selectElements(Document document) - { - return document.select("link[type=text/css][href]"); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - @Override - protected String getExtension() - { - return EXTENSION; - } - - /** - * Method description - * - * - * @param inputDirectory - * @param element - * - * @return - */ - @Override - protected File getFile(File inputDirectory, Element element) - { - return new File(inputDirectory, element.attr("href")); - } -}