mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
install plugins in the right order
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 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.plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class PluginCircularDependencyException extends PluginException
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -4163410666933840934L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public PluginCircularDependencyException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
66
scm-core/src/main/java/sonia/scm/plugin/PluginConstants.java
Normal file
66
scm-core/src/main/java/sonia/scm/plugin/PluginConstants.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* 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.plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public interface PluginConstants
|
||||
{
|
||||
|
||||
/** descriptor xml element artifactId */
|
||||
public static final String EL_ARTIFACTID = "artifactId";
|
||||
|
||||
/** descriptor xml element dependency */
|
||||
public static final String EL_DEPENDENCY = "dependency";
|
||||
|
||||
/** descriptor xml element groupId */
|
||||
public static final String EL_GROUPID = "groupId";
|
||||
|
||||
/** descriptor xml element version */
|
||||
public static final String EL_VERSION = "version";
|
||||
|
||||
/** checksum file */
|
||||
public static final String FILE_CHECKSUM = "checksum";
|
||||
|
||||
/** core file */
|
||||
public static final String FILE_CORE = "core";
|
||||
|
||||
/** Field description */
|
||||
public static final String PATH_DESCRIPTOR =
|
||||
"/WEB-INF/classes/META-INF/scm/plugin.xml";
|
||||
|
||||
/** Field description */
|
||||
public static final String FILE_DESCRIPTOR = PATH_DESCRIPTOR.substring(1);
|
||||
}
|
||||
@@ -74,20 +74,6 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
*/
|
||||
public final class SmpArchive
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String PATH_DESCRIPTOR =
|
||||
"/WEB-INF/classes/META-INF/scm/plugin.xml";
|
||||
|
||||
/** Field description */
|
||||
private static final String EL_ARTIFACTID = "artifactId";
|
||||
|
||||
/** Field description */
|
||||
private static final String EL_GROUPID = "groupId";
|
||||
|
||||
/** Field description */
|
||||
private static final String EL_VERSION = "version";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -316,7 +302,7 @@ public final class SmpArchive
|
||||
|
||||
while (entry != null)
|
||||
{
|
||||
if (PATH_DESCRIPTOR.equals(getPath(entry)))
|
||||
if (PluginConstants.PATH_DESCRIPTOR.equals(getPath(entry)))
|
||||
{
|
||||
doc = XmlUtil.createDocument(zis);
|
||||
}
|
||||
@@ -352,16 +338,23 @@ public final class SmpArchive
|
||||
*/
|
||||
private PluginId createPluginId() throws IOException
|
||||
{
|
||||
Multimap<String, String> entries = XmlUtil.values(getDescriptorDocument(),
|
||||
EL_GROUPID, EL_ARTIFACTID, EL_VERSION);
|
||||
String groupId = getSingleValue(entries, EL_GROUPID);
|
||||
//J-
|
||||
Multimap<String, String> entries = XmlUtil.values(
|
||||
getDescriptorDocument(),
|
||||
PluginConstants.EL_GROUPID,
|
||||
PluginConstants.EL_ARTIFACTID,
|
||||
PluginConstants.EL_VERSION
|
||||
);
|
||||
//J+
|
||||
|
||||
String groupId = getSingleValue(entries, PluginConstants.EL_GROUPID);
|
||||
|
||||
if (Strings.isNullOrEmpty(groupId))
|
||||
{
|
||||
throw new PluginException("could not find groupId in plugin descriptor");
|
||||
}
|
||||
|
||||
String artifactId = getSingleValue(entries, EL_ARTIFACTID);
|
||||
String artifactId = getSingleValue(entries, PluginConstants.EL_ARTIFACTID);
|
||||
|
||||
if (Strings.isNullOrEmpty(artifactId))
|
||||
{
|
||||
@@ -369,7 +362,7 @@ public final class SmpArchive
|
||||
"could not find artifactId in plugin descriptor ");
|
||||
}
|
||||
|
||||
String version = getSingleValue(entries, EL_VERSION);
|
||||
String version = getSingleValue(entries, PluginConstants.EL_VERSION);
|
||||
|
||||
if (Strings.isNullOrEmpty(version))
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ package sonia.scm.util;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -428,6 +429,24 @@ public final class Util
|
||||
return parseDate(dateString, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first value of a {@link Multimap} or {@code null}.
|
||||
*
|
||||
*
|
||||
* @param map multi map
|
||||
* @param key key
|
||||
* @param <K> type of key
|
||||
* @param <V> type of
|
||||
*
|
||||
* @return first value of {@code null}
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public static <K, V> V getFirst(Multimap<K, V> map, K key)
|
||||
{
|
||||
return map.get(key).iterator().next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -36,7 +36,6 @@ package sonia.scm.plugin;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import org.junit.Rule;
|
||||
@@ -92,7 +91,7 @@ public class SmpArchiveTest
|
||||
IOUtil.mkdirs(target);
|
||||
SmpArchive.create(archive).extract(target);
|
||||
|
||||
File descriptor = new File(target, SmpArchive.PATH_DESCRIPTOR.substring(1));
|
||||
File descriptor = new File(target, PluginConstants.FILE_DESCRIPTOR);
|
||||
|
||||
assertTrue(descriptor.exists());
|
||||
|
||||
@@ -201,7 +200,7 @@ public class SmpArchiveTest
|
||||
try (ZipOutputStream zos =
|
||||
new ZipOutputStream(new FileOutputStream(archiveFile), Charsets.UTF_8))
|
||||
{
|
||||
zos.putNextEntry(new ZipEntry(SmpArchive.PATH_DESCRIPTOR));
|
||||
zos.putNextEntry(new ZipEntry(PluginConstants.PATH_DESCRIPTOR));
|
||||
Files.copy(descriptor, zos);
|
||||
zos.closeEntry();
|
||||
zos.putNextEntry(new ZipEntry("/META-INF/"));
|
||||
|
||||
Reference in New Issue
Block a user