From 904c25a30fab109eb6f94b27a706afdcc9d2e74a Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Mon, 6 Aug 2018 07:25:33 +0200 Subject: [PATCH 01/16] Add imagej-maven-plugin's sources The sources are based on imagej/imagej-maven-plugin#9240da2 with the sources moved into the correct packages already. In addition to the already available imagej.* properties, scijava.* properties have been added with compatibility between those properties. --- .../plugin/install/AbstractCopyJarsMojo.java | 311 +++++++++++++ .../maven/plugin/install/CopyJarsMojo.java | 292 ++++++++++++ .../plugin/install/InstallArtifactMojo.java | 435 ++++++++++++++++++ 3 files changed, 1038 insertions(+) create mode 100644 src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java create mode 100644 src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java create mode 100644 src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java diff --git a/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java b/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java new file mode 100644 index 0000000..396ccb1 --- /dev/null +++ b/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java @@ -0,0 +1,311 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ + +package org.scijava.maven.plugin.install; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Dependency; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.interpolation.EnvarBasedValueSource; +import org.codehaus.plexus.interpolation.ObjectBasedValueSource; +import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; +import org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper; +import org.codehaus.plexus.interpolation.PropertiesBasedValueSource; +import org.codehaus.plexus.interpolation.RecursionInterceptor; +import org.codehaus.plexus.interpolation.RegexBasedInterpolator; +import org.codehaus.plexus.util.FileUtils; +import org.scijava.util.VersionUtils; + +/** + * Base class for mojos to copy .jar artifacts and their dependencies into a + * SciJava application directory structure. + * + * @author Johannes Schindelin + */ +public abstract class AbstractCopyJarsMojo extends AbstractMojo { + + public static final String imagejDirectoryProperty = "imagej.app.directory"; + public static final String imagejSubdirectoryProperty = "imagej.app.subdirectory"; + public static final String deleteOtherVersionsProperty = "delete.other.versions"; + public static final String imagejDeleteOtherVersionsPolicyProperty = "imagej.deleteOtherVersions"; + + public static final String appDirectoryProperty = "scijava.app.directory"; + public static final String appSubdirectoryProperty = "scijava.app.subdirectory"; + public static final String deleteOtherVersionsPolicyProperty = "scijava.deleteOtherVersions"; + public static final String ignoreDependenciesProperty = "scijava.ignoreDependencies"; + + public enum OtherVersions { + always, older, never + } + + protected boolean hasIJ1Dependency(final MavenProject project) { + final List dependencies = project.getDependencies(); + for (final Dependency dependency : dependencies) { + final String artifactId = dependency.getArtifactId(); + if ("ij".equals(artifactId) || "imagej".equals(artifactId)) return true; + } + return false; + } + + protected String interpolate(final String original, + final MavenProject project, final MavenSession session) + throws MojoExecutionException + { + if (original == null || original.indexOf("${") < 0) return original; + try { + RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); + + interpolator.addValueSource(new EnvarBasedValueSource()); + interpolator.addValueSource(new PropertiesBasedValueSource(System + .getProperties())); + + List synonymPrefixes = new ArrayList<>(); + synonymPrefixes.add("project."); + synonymPrefixes.add("pom."); + + if (project != null) { + PrefixedValueSourceWrapper modelWrapper = + new PrefixedValueSourceWrapper(new ObjectBasedValueSource(project + .getModel()), synonymPrefixes, true); + interpolator.addValueSource(modelWrapper); + + PrefixedValueSourceWrapper pomPropertyWrapper = + new PrefixedValueSourceWrapper(new PropertiesBasedValueSource(project + .getModel().getProperties()), synonymPrefixes, true); + interpolator.addValueSource(pomPropertyWrapper); + } + + if (session != null) { + interpolator.addValueSource(new PropertiesBasedValueSource(session + .getExecutionProperties())); + } + + RecursionInterceptor recursionInterceptor = + new PrefixAwareRecursionInterceptor(synonymPrefixes, true); + return interpolator.interpolate(original, recursionInterceptor); + } + catch (Exception e) { + throw new MojoExecutionException("Could not interpolate '" + original + + "'", e); + } + } + + protected void installArtifact(final Artifact artifact, + final File imagejDirectory, final boolean force, + final OtherVersions otherVersionsPolicy) throws IOException + { + installArtifact(artifact, imagejDirectory, "", force, otherVersionsPolicy); + } + + protected void installArtifact(final Artifact artifact, + final File imagejDirectory, final String subdirectory, final boolean force, + final OtherVersions otherVersionsPolicy) throws IOException + { + if (!"jar".equals(artifact.getType())) return; + + final File source = artifact.getFile(); + final File targetDirectory; + + if (subdirectory != null && !subdirectory.equals("")) { + targetDirectory = new File(imagejDirectory, subdirectory); + } else if (isIJ1Plugin(source)) { + targetDirectory = new File(imagejDirectory, "plugins"); + } + else if ("ome".equals(artifact.getGroupId()) || + ("loci".equals(artifact.getGroupId()) && (source.getName().startsWith( + "scifio-4.4.") || source.getName().startsWith("jai_imageio-4.4.")))) + { + targetDirectory = new File(imagejDirectory, "jars/bio-formats"); + } + else { + targetDirectory = new File(imagejDirectory, "jars"); + } + final String fileName = "Fiji_Updater".equals(artifact.getArtifactId()) + ? artifact.getArtifactId() + ".jar" : source.getName(); + final File target = new File(targetDirectory, fileName); + + boolean newerVersion = false; + final Path directoryPath = Paths.get(imagejDirectory.toURI()); + final Path targetPath = Paths.get(target.toURI()); + final Collection otherVersions = // + getEncroachingVersions(directoryPath, targetPath); + if (otherVersions != null && !otherVersions.isEmpty()) { + for (final Path other : otherVersions) { + final Path otherName = other.getFileName(); + switch (otherVersionsPolicy) { + case never: + getLog().warn("Possibly incompatible version exists: " + otherName); + break; + case older: + final String toInstall = artifact.getVersion(); + final Matcher matcher = versionPattern.matcher(otherName.toString()); + if (!matcher.matches()) break; + final String group = matcher.group(VERSION_INDEX); + if (group == null) { + newerVersion = true; + getLog().warn("Impenetrable version suffix for file: " + + otherName); + } + else { + final String otherVersion = group.substring(1); + newerVersion = VersionUtils.compare(toInstall, otherVersion) < 0; + if (majorVersion(toInstall) != majorVersion(otherVersion)) { + getLog().warn( + "Found other version that is incompatible according to SemVer: " + + otherVersion); + } + } + if (newerVersion) break; + //$FALL-THROUGH$ + case always: + if (Files.deleteIfExists(other)) { + getLog().info("Deleted overridden " + otherName); + newerVersion = false; + } + else getLog().warn("Could not delete overridden " + otherName); + break; + } + } + } + + if (!force && target.exists() && + target.lastModified() > source.lastModified()) + { + getLog().info("Dependency " + fileName + " is already there; skipping"); + } + else if (newerVersion) { + getLog().info("A newer version for " + fileName + " was detected; skipping"); + } + else { + getLog().info("Copying " + fileName + " to " + targetDirectory); + FileUtils.copyFile(source, target); + } + } + + private static boolean isIJ1Plugin(final File file) { + final String name = file.getName(); + if (name.indexOf('_') < 0 || !file.exists()) return false; + if (file.isDirectory()) { + return new File(file, "src/main/resources/plugins.config").exists(); + } + if (!name.endsWith(".jar")) return false; + + try (final JarFile jar = new JarFile(file)) { + for (final JarEntry entry : Collections.list(jar.entries())) { + if (entry.getName().equals("plugins.config")) { + jar.close(); + return true; + } + } + } + catch (final Throwable t) { + // obviously not a plugin... + } + return false; + } + + private final static Pattern versionPattern = Pattern.compile("(.+?)" + + "(-\\d+(\\.\\d+|\\d{7})+[a-z]?\\d?(-[A-Za-z0-9.]+?|\\.GA)*?)?" + + "((-(swing|swt|sources|javadoc|native|linux-x86|linux-x86_64|macosx-x86_64|windows-x86|windows-x86_64|android-arm|android-x86|natives-windows|natives-macos|natives-linux))?(\\.jar(-[a-z]*)?))"); + private final static int PREFIX_INDEX = 1; + private final static int VERSION_INDEX = 2; + private final static int SUFFIX_INDEX = 5; + + /** + * Extracts the major version (according to SemVer) from a version string. + * If no dot is found, the input is returned. + * + * @param v + * SemVer version string + * @return The major version (according to SemVer) as {@code String}. + */ + private String majorVersion( String v ) + { + final int dot = v.indexOf('.'); + return dot < 0 ? v : v.substring(0, dot); + } + + /** + * Looks for files in {@code directory} with the same base name as + * {@code file}. + * + * @param directory The directory to walk to find possible duplicates. + * @param file A {@link Path} to the target (from which the base name is + * derived). + * @return A collection of {@link Path}s to files of the same base name. + */ + private Collection getEncroachingVersions(final Path directory, final Path file) { + final Matcher matcher = versionPattern.matcher(file.getFileName().toString()); + if (!matcher.matches()) return null; + + final String prefix = matcher.group(PREFIX_INDEX); + final String suffix = matcher.group(SUFFIX_INDEX); + + Collection result = new ArrayList<>(); + try { + result = Files.walk(directory) + .filter(path -> path.getFileName().toString().startsWith(prefix)) + .filter(path -> { + final Matcher matcherIterator = versionPattern.matcher(path.getFileName().toString()); + return matcherIterator.matches() && + prefix.equals(matcherIterator.group(PREFIX_INDEX)) && + suffix.equals(matcherIterator.group(SUFFIX_INDEX)); + }) + .filter(path -> !path.getFileName().toString().equals(file.getFileName().toString())) + .collect(Collectors.toCollection(ArrayList::new)); + return result; + } catch (IOException e) { + getLog().error(e); + } finally { + result = new ArrayList<>(); + } + + return result; + } +} diff --git a/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java new file mode 100644 index 0000000..7d124b3 --- /dev/null +++ b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java @@ -0,0 +1,292 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ + +package org.scijava.maven.plugin.install; + +import java.io.File; +import java.io.IOException; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.PluginParameterExpressionEvaluator; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.DefaultProjectBuildingRequest; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter; +import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; +import org.apache.maven.shared.artifact.resolve.ArtifactResult; +import org.apache.maven.shared.dependencies.DefaultDependableCoordinate; +import org.apache.maven.shared.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.dependencies.resolve.DependencyResolverException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; + +/** + * Copies .jar artifacts and their dependencies into a SciJava application + * directory structure. + * + * @author Johannes Schindelin + * @author Stefan Helfrich + */ +@Mojo(name = "copy-jars", requiresProject = true, requiresOnline = true) +public class CopyJarsMojo extends AbstractCopyJarsMojo { + + /** + * Path to the ImageJ.app/ directory to which artifacts are copied. + *

+ * If it is not a directory, no .jar files are copied. + *

+ */ + @Deprecated + @Parameter(property = imagejDirectoryProperty, required = false) + private String imagejDirectory; + + /** + * Path to a SciJava application directory (e.g. ImageJ.app) to which + * artifacts are copied. + *

+ * If it is not a directory, no .jar files are copied. + *

+ */ + @Parameter(property = appDirectoryProperty, required = false) + private String appDirectory; + + /** + * The name of the property pointing to the subdirectory (beneath e.g. + * {@code jars/} or {@code plugins/}) to which the artifact should be copied. + *

+ * If no property of that name exists, no subdirectory will be used. + *

+ */ + @Deprecated + @Parameter(property = imagejSubdirectoryProperty, required = false) + private String imagejSubdirectory; + + /** + * The name of the property pointing to the subdirectory (beneath e.g. + * {@code jars/} or {@code plugins/}) to which the artifact should be copied. + *

+ * If no property of that name exists, no subdirectory will be used. + *

+ */ + @Parameter(property = appSubdirectoryProperty, required = false) + private String appSubdirectory; + + /** + * Whether to delete other versions when copying the files. + *

+ * When copying a file and its dependencies to an ImageJ.app/ directory and + * there are other versions of the same file, we can warn or delete those + * other versions. + *

+ */ + @Deprecated + @Parameter(property = deleteOtherVersionsProperty) + private boolean deleteOtherVersions; + + /** + * Whether to delete other versions when copying the files. + *

+ * When copying a file and its dependencies to an ImageJ.app/ directory and + * there are other versions of the same file, we can warn or delete those + * other versions. + *

+ */ + @Deprecated + @Parameter(property = imagejDeleteOtherVersionsPolicyProperty, defaultValue = "older") + private OtherVersions imagejDeleteOtherVersionsPolicy; + + /** + * Whether to delete other versions when copying the files. + *

+ * When copying a file and its dependencies to a SciJava application directory + * and there are other versions of the same file, we can warn or delete those + * other versions. + *

+ */ + @Parameter(property = deleteOtherVersionsPolicyProperty, defaultValue = "older") + private OtherVersions deleteOtherVersionsPolicy; + + /** + * If this option is set to true, only the artifact will be + * copied - without its dependencies. + */ + @Parameter(property = ignoreDependenciesProperty, defaultValue = "false") + private boolean ignoreDependencies; + + /** + * Project + */ + @Parameter(defaultValue = "${project}", required=true, readonly = true) + private MavenProject project; + + /** + * Session + */ + @Parameter(defaultValue = "${session}") + private MavenSession session; + + /** + * The dependency resolver to. + */ + @Component + private DependencyResolver dependencyResolver; + + private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); + + private File appDir; + + @Parameter( defaultValue = "${mojoExecution}", readonly = true ) + MojoExecution mojoExecution; + + @Override + public void execute() throws MojoExecutionException { + ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); + + // Keep backwards compatibility to delete.other.versions + try { + Object evaluate = evaluator.evaluate("${"+deleteOtherVersionsProperty+"}"); + if (evaluate != null) { + getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + + // Keep backwards compatibility to imagej.app.directory + try { + Object evaluate = evaluator.evaluate("${"+imagejDirectoryProperty+"}"); + if (evaluate != null) { + getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); + + // TODO How do we want to handle cases where both are provided. Which + // property should take precedence? + appDirectory = imagejDirectory; + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + + // Keep backwards compatibility to imagej.app.subdirectory + try { + Object evaluate = evaluator.evaluate("${"+imagejSubdirectoryProperty+"}"); + if (evaluate != null) { + getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); + + // TODO How do we want to handle cases where both are provided. Which + // property should take precedence? + appSubdirectory = imagejSubdirectory; + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + + // Keep backwards compatibility to imagej.deleteOtherVersions + try { + Object evaluate = evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}"); + if (evaluate != null) { + getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + + // TODO How do we want to handle cases where both are provided. Which + // property should take precedence? + deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + + if (appDirectory == null) { + if (hasIJ1Dependency(project)) getLog().info( + "Property '" + appDirectoryProperty + "' unset; Skipping copy-jars"); + return; + } + final String interpolated = interpolate(appDirectory, project, session); + appDir = new File(interpolated); + + if (appSubdirectory == null) { + getLog().info("No property name for the " + appSubdirectoryProperty + + " directory location was specified; Installing in default location"); + } + + if (!appDir.isDirectory()) { + getLog().warn( + "'" + appDirectory + "'" + + (interpolated.equals(appDirectory) ? "" : " (" + appDirectory + ")") + + " is not an SciJava application directory; Skipping copy-jars"); + return; + } + + // Initialize coordinate for resolving + coordinate.setGroupId(project.getGroupId()); + coordinate.setArtifactId(project.getArtifactId()); + coordinate.setVersion(project.getVersion()); + coordinate.setType(project.getPackaging()); + + try { + TransformableFilter scopeFilter = ScopeFilter.excluding("system", "provided", "test"); + + ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); + buildingRequest.setProject( project ); + + Iterable resolveDependencies = dependencyResolver + .resolveDependencies(buildingRequest, coordinate, scopeFilter); + for (ArtifactResult result : resolveDependencies) { + try { + if (project.getArtifact().equals(result.getArtifact())) { + installArtifact(result.getArtifact(), appDir, appSubdirectory, false, + deleteOtherVersionsPolicy); + continue; + } + // Resolution of the subdirectory for dependencies is handled in installArtifact + if (!ignoreDependencies) + installArtifact(result.getArtifact(), appDir, false, deleteOtherVersionsPolicy); + } + catch (IOException e) { + throw new MojoExecutionException("Couldn't download artifact " + + result.getArtifact() + ": " + e.getMessage(), e); + } + } + } + catch (DependencyResolverException e) { + throw new MojoExecutionException( + "Couldn't resolve dependencies for artifact: " + e.getMessage(), e); + } + } +} diff --git a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java new file mode 100644 index 0000000..bdd73b3 --- /dev/null +++ b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java @@ -0,0 +1,435 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ + +package org.scijava.maven.plugin.install; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; +import org.apache.maven.artifact.repository.MavenArtifactRepository; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.PluginParameterExpressionEvaluator; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.DefaultProjectBuildingRequest; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.shared.artifact.filter.resolve.AbstractFilter; +import org.apache.maven.shared.artifact.filter.resolve.AndFilter; +import org.apache.maven.shared.artifact.filter.resolve.Node; +import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter; +import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; +import org.apache.maven.shared.artifact.resolve.ArtifactResolver; +import org.apache.maven.shared.artifact.resolve.ArtifactResult; +import org.apache.maven.shared.dependencies.DefaultDependableCoordinate; +import org.apache.maven.shared.dependencies.DependableCoordinate; +import org.apache.maven.shared.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.dependencies.resolve.DependencyResolverException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.util.StringUtils; + +/** + * Downloads .jar artifacts and their dependencies into an ImageJ.app/ directory + * structure. + * + * @author Johannes Schindelin + */ +@Mojo(name = "install-artifact", requiresProject=false) +public class InstallArtifactMojo extends AbstractCopyJarsMojo { + + /** + * Path to the ImageJ.app/ directory to which artifacts are installed. + *

+ * If it is not a directory, no .jar files are copied. + *

+ */ + @Parameter(property = imagejDirectoryProperty) + private String imagejDirectory; + + /** + * The name of the property pointing to the subdirectory (beneath e.g. + * {@code jars/} or {@code plugins/}) to which the artifact should be + * copied. + *

+ * If no property of that name exists, no subdirectory will be used. + *

+ */ + @Parameter( property = imagejSubdirectoryProperty, required = false ) + private String imagejSubdirectory; + + /** + * Whether to delete other versions when copying the files. + *

+ * When copying a file and its dependencies to an ImageJ.app/ directory and + * there are other versions of the same file, we can warn or delete those + * other versions. + *

+ */ + @Deprecated + @Parameter(property = deleteOtherVersionsProperty) + private boolean deleteOtherVersions; + + /** + * Whether to delete other versions when copying the files. + *

+ * When copying a file and its dependencies to an ImageJ.app/ directory and + * there are other versions of the same file, we can warn or delete those + * other versions. + *

+ */ + @Parameter(property = imagejDeleteOtherVersionsPolicyProperty, defaultValue = "older") + private OtherVersions deleteOtherVersionsPolicy; + + /** + * If this option is set to true, only the artifact will be + * copied - without its dependencies. + */ + @Parameter(property = ignoreDependenciesProperty, defaultValue = "false") + private boolean ignoreDependencies; + + /** + * Session + */ + @Parameter(defaultValue = "${session}") + private MavenSession session; + + /** + * Used to look up Artifacts in the remote repository. + */ + @Component + private ArtifactResolver artifactResolver; + + @Component + private ArtifactRepositoryFactory artifactRepositoryFactory; + + /** + * Location of the local repository. + */ + @Parameter(property = "localRepository", readonly = true) + private ArtifactRepository localRepository; + + /** + * Map that contains the layouts. + */ + @Component(role = ArtifactRepositoryLayout.class) + private Map repositoryLayouts; + + private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.*)::(.+)" ); + + /** + * Repositories in the format id::[layout]::url or just url, separated by + * comma. ie. + * central::default::http://repo1.maven.apache.org/maven2,myrepo::::http://repo.acme.com,http://repo.acme2.com + */ + @Parameter(property = "remoteRepositories") + private String remoteRepositories; + + /** + * Remote repositories from POM + */ + @Parameter(defaultValue = "${project.remoteArtifactRepositories}", + readonly = true, required = true) + private List pomRemoteRepositories; + + /** + * The groupId of the artifact to download. Ignored if {@link #artifact} is + * used. + */ + @Parameter(property = "groupId") + private String groupId; + + /** + * The artifactId of the artifact to download. Ignored if {@link #artifact} is + * used. + */ + @Parameter(property="artifactId") + private String artifactId; + + /** + * The version of the artifact to download. Ignored if {@link #artifact} is + * used. + */ + @Parameter(property="version") + private String version; + + /** + * The packaging of the artifact to download. Ignored if {@link #artifact} is + * used. + */ + @Parameter(property = "packaging", defaultValue = "jar") + private String packaging = "jar"; + + /** + * A string of the form groupId:artifactId:version[:packaging]. + */ + @Parameter(property = "artifact") + private String artifact; + + /** + * The dependency resolver to. + */ + @Component + private DependencyResolver dependencyResolver; + + /** + * Whether to force overwriting files. + */ + @Parameter(property = "force") + private boolean force; + + /** + * The coordinate use for resolving dependencies. + */ + private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); + + @Parameter( defaultValue = "${mojoExecution}", readonly = true ) + MojoExecution mojoExecution; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + // Keep backwards compatibility to delete.other.versions + ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); + try { + Object evaluate = evaluator.evaluate("${"+deleteOtherVersionsProperty+"}"); + if (evaluate != null) { + getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ imagejDeleteOtherVersionsPolicyProperty +"' instead"); + deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + + if (imagejDirectory == null) { + throw new MojoExecutionException( + "The '"+imagejDirectoryProperty+"' property is unset!"); + } + File imagejDir = new File(imagejDirectory); + if (!imagejDir.isDirectory() && !imagejDir.mkdirs()) { + throw new MojoFailureException("Could not make directory: " + + imagejDir); + } + + if ( imagejSubdirectory == null ) + { + getLog().info( "No property name for the " + imagejSubdirectoryProperty + + " directory location was specified; Installing in default location" ); + } + + ArtifactRepositoryPolicy always = new ArtifactRepositoryPolicy(true, + ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, + ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN); + + List repoList = new ArrayList<>(); + + // Use repositories provided in POM (if available) + if (pomRemoteRepositories != null) { + repoList.addAll(pomRemoteRepositories); + } + + // Add remote repositories provided as parameter + if (remoteRepositories != null) { + String[] repos = remoteRepositories.split(","); + for (String repo : repos) { + repoList.add(parseRepository(repo, always)); + } + } + + // Add ImageJ remote repository + repoList.add(parseRepository("http://maven.imagej.net/content/groups/public", always)); + + /* + * Determine GAV to download + */ + if (artifactId == null && artifact == null) { + throw new MojoFailureException( + "No artifact specified (e.g. by -Dartifact=net.imagej:ij:1.48p)"); + } + if (artifact != null) { + String[] tokens = artifact.split(":"); + parseArtifact(tokens); + } + + /* + * Install artifact + */ + try { + ProjectBuildingRequest buildingRequest = + new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); + buildingRequest.setLocalRepository(localRepository); + buildingRequest.setRemoteRepositories(repoList); + + TransformableFilter scopeFilter = ScopeFilter.excluding("system", "provided", "test"); + TransformableFilter notOptionalFilter = new AbstractFilter() { + @Override + public boolean accept(Node node, List parents) { + return !node.getDependency().isOptional(); + } + }; + TransformableFilter scopeAndNotOptionalFilter = new AndFilter(Arrays.asList(scopeFilter, notOptionalFilter)); + + Iterable resolveDependencies = dependencyResolver + .resolveDependencies(buildingRequest, coordinate, scopeAndNotOptionalFilter); + for (ArtifactResult result : resolveDependencies) { + try { + if ( isSameGAV(coordinate, result.getArtifact()) ) + { + installArtifact( result.getArtifact(), imagejDir, imagejSubdirectory, false, deleteOtherVersionsPolicy ); + continue; + } + if (!ignoreDependencies) + installArtifact(result.getArtifact(), imagejDir, false, + deleteOtherVersionsPolicy); + } + catch (IOException e) { + throw new MojoExecutionException("Couldn't download artifact " + + artifact + ": " + e.getMessage(), e); + } + } + } + catch (DependencyResolverException e) { + throw new MojoExecutionException( + "Couldn't resolve dependencies for artifact: " + e.getMessage(), e); + } + } + + /** + * Checks if a {@link DependableCoordinate} and an {@link Artifact} share + * the same GAV. + * + * @param coordinateToCompare + * a {@link DependableCoordinate} instance + * @param artifactToCompare + * an {@link Artifact} instance + * @return true if both parameters share the same GAV; false otherwise + */ + private boolean isSameGAV(final DependableCoordinate coordinateToCompare, final Artifact artifactToCompare) { + boolean same = coordinateToCompare.getGroupId().equals(artifactToCompare.getGroupId()); + same = same && coordinateToCompare.getArtifactId().equals(artifactToCompare.getArtifactId()); + same = same && coordinateToCompare.getVersion().equals(artifactToCompare.getVersion()); + return same; + } + + /** + * Parses an artifact string of form + * {@code groupId:artifactId:version[:packaging]}. + * + * @param tokens + * @throws MojoFailureException + */ + private void parseArtifact(final String[] tokens) throws MojoFailureException { + if (tokens.length != 3) { + throw new MojoFailureException( + "Invalid artifact, you must specify groupId:artifactId:version " + + artifact); + } + groupId = tokens[0]; + artifactId = tokens[1]; + version = tokens[2]; + + coordinate.setGroupId(groupId); + coordinate.setArtifactId(artifactId); + coordinate.setVersion(version); + + if (tokens.length == 4) { + coordinate.setType(tokens[3]); + } + } + + /** + * Parses repository string of form [id::layout::]url + * + * @param repository {@link String} to be parsed + * @param policy The {@link ArtifactRepositoryPolicy} for the repository + * @return an {@link ArtifactRepository} instance + * @throws MojoFailureException + */ + private ArtifactRepository parseRepository(final String repository, + final ArtifactRepositoryPolicy policy) throws MojoFailureException + { + // if it's a simple url + String id = "temp"; + ArtifactRepositoryLayout layout = getLayout("default"); + String url = repository; + + // if it's an extended repo URL of the form id::layout::url + if (repository.contains("::")) { + Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(repository); + if (!matcher.matches()) { + throw new MojoFailureException(repository, + "Invalid syntax for repository: " + repository, + "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"."); + } + + id = matcher.group(1).trim(); + if (!StringUtils.isEmpty(matcher.group(2))) { + layout = getLayout(matcher.group(2).trim()); + } + url = matcher.group(3).trim(); + } + return new MavenArtifactRepository(id, url, layout, policy, policy); + } + + /** + * Determines the layout of a provided repository. + * + * @param id Id to be queried. + * @return An {@link ArtifactRepositoryLayout} instance. + * @throws MojoFailureException + */ + private ArtifactRepositoryLayout getLayout(final String id) + throws MojoFailureException + { + ArtifactRepositoryLayout layout = repositoryLayouts.get(id); + + if (layout == null) { + throw new MojoFailureException(id, "Invalid repository layout", + "Invalid repository layout: " + id); + } + + return layout; + } +} From e89cc12be2c90707193d08dbed63f5bd9bd0a44d Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Thu, 9 Aug 2018 07:14:56 +0200 Subject: [PATCH 02/16] Add more detailed Javadocs --- .../scijava/maven/plugin/install/CopyJarsMojo.java | 8 ++++++++ .../maven/plugin/install/InstallArtifactMojo.java | 13 +++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java index 7d124b3..bbefd51 100644 --- a/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java @@ -57,6 +57,14 @@ * Copies .jar artifacts and their dependencies into a SciJava application * directory structure. * + * ImageJ 1.x plugins (identified by containing a plugins.config file) get + * copied to the plugins/ subdirectory and all other .jar files to jars/. + * However, you can override this decision by setting the scijava.app.subdirectory + * property to a specific subdirectory. It expects the location of the SciJava + * application directory to be specified in the scijava.app.directory property + * (which can be set on the Maven command-line). If said property is not set, + * the copy-jars goal is skipped. + * * @author Johannes Schindelin * @author Stefan Helfrich */ diff --git a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java index bdd73b3..6d29f03 100644 --- a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java @@ -72,10 +72,19 @@ import org.codehaus.plexus.util.StringUtils; /** - * Downloads .jar artifacts and their dependencies into an ImageJ.app/ directory - * structure. + * Downloads .jar artifacts and their dependencies into a SciJava application + * directory structure. + * + * ImageJ 1.x plugins (identified by containing a plugins.config file) get + * copied to the plugins/ subdirectory and all other .jar files to jars/. + * However, you can override this decision by setting the scijava.app.subdirectory + * property to a specific subdirectory. It expects the location of the SciJava + * application directory to be specified in the scijava.app.directory property + * (which can be set on the Maven command-line). If said property is not set, + * the install-artifact goal is skipped. * * @author Johannes Schindelin + * @author Stefan Helfrich */ @Mojo(name = "install-artifact", requiresProject=false) public class InstallArtifactMojo extends AbstractCopyJarsMojo { From 54d3593f7e84a9901faaa6696be9d9d103704373 Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Mon, 6 Aug 2018 07:25:16 +0200 Subject: [PATCH 03/16] Add imagej-maven-plugin's integration tests --- src/it/copy-jars/pom.xml | 89 +++++++++++++++++++ src/it/copy-jars/setup.bsh | 34 +++++++ .../src/main/java/Example_PlugIn.java | 44 +++++++++ .../src/main/resources/plugins.config | 31 +++++++ src/it/copy-jars/verify.bsh | 41 +++++++++ src/it/copy-to-subdirectory/pom.xml | 85 ++++++++++++++++++ src/it/copy-to-subdirectory/setup.bsh | 33 +++++++ .../src/main/resources/plugins.config | 31 +++++++ src/it/copy-to-subdirectory/verify.bsh | 39 ++++++++ .../pom.xml | 67 ++++++++++++++ .../setup.bsh | 34 +++++++ .../src/main/resources/plugins.config | 31 +++++++ .../verify.bsh | 35 ++++++++ .../pom.xml | 68 ++++++++++++++ .../setup.bsh | 40 +++++++++ .../src/main/resources/plugins.config | 31 +++++++ .../verify.bsh | 39 ++++++++ src/it/delete-other-versions-policy/pom.xml | 77 ++++++++++++++++ src/it/delete-other-versions-policy/setup.bsh | 44 +++++++++ .../src/main/resources/plugins.config | 31 +++++++ .../delete-other-versions-policy/verify.bsh | 52 +++++++++++ .../pom.xml | 65 ++++++++++++++ .../setup.bsh | 34 +++++++ .../src/main/resources/plugins.config | 31 +++++++ .../verify.bsh | 35 ++++++++ .../pom.xml | 65 ++++++++++++++ .../setup.bsh | 34 +++++++ .../src/main/resources/plugins.config | 31 +++++++ .../verify.bsh | 35 ++++++++ src/it/do-not-delete-natives/pom.xml | 67 ++++++++++++++ src/it/do-not-delete-natives/setup.bsh | 34 +++++++ .../src/main/resources/plugins.config | 31 +++++++ src/it/do-not-delete-natives/verify.bsh | 35 ++++++++ src/it/exclusions/dependency/pom.xml | 48 ++++++++++ .../dependency/src/main/resources/empty.txt | 0 src/it/exclusions/excluded/pom.xml | 41 +++++++++ .../excluded/src/main/resources/empty.txt | 0 src/it/exclusions/pom.xml | 50 +++++++++++ src/it/exclusions/setup.bsh | 33 +++++++ src/it/exclusions/to-copy/pom.xml | 78 ++++++++++++++++ .../to-copy/src/main/resources/empty.txt | 0 src/it/exclusions/verify.bsh | 36 ++++++++ src/it/handle-missing-version-numbers/pom.xml | 65 ++++++++++++++ .../handle-missing-version-numbers/setup.bsh | 35 ++++++++ .../src/main/resources/empty.txt | 0 .../handle-missing-version-numbers/verify.bsh | 39 ++++++++ src/it/ignore-dependencies/pom.xml | 85 ++++++++++++++++++ src/it/ignore-dependencies/setup.bsh | 33 +++++++ .../src/main/resources/plugins.config | 31 +++++++ src/it/ignore-dependencies/verify.bsh | 39 ++++++++ .../only-local/pom.xml | 41 +++++++++ .../only-local/src/main/resources/empty.txt | 0 src/it/install-from-local-repo/pom.xml | 49 ++++++++++ src/it/install-from-local-repo/setup.bsh | 33 +++++++ .../install-from-local-repo/to-copy/pom.xml | 83 +++++++++++++++++ .../to-copy/src/main/resources/empty.txt | 0 src/it/install-from-local-repo/verify.bsh | 40 +++++++++ src/it/lib.bsh | 73 +++++++++++++++ src/it/missing-property/pom.xml | 71 +++++++++++++++ src/it/missing-property/verify.bsh | 37 ++++++++ src/it/no-nag/pom.xml | 63 +++++++++++++ src/it/no-nag/verify.bsh | 37 ++++++++ src/it/settings.xml | 66 ++++++++++++++ src/it/skip-copy-jars/pom.xml | 72 +++++++++++++++ src/it/skip-copy-jars/verify.bsh | 37 ++++++++ src/it/skip-optional/pom.xml | 76 ++++++++++++++++ src/it/skip-optional/setup.bsh | 33 +++++++ src/it/skip-optional/verify.bsh | 35 ++++++++ 68 files changed, 2932 insertions(+) create mode 100644 src/it/copy-jars/pom.xml create mode 100644 src/it/copy-jars/setup.bsh create mode 100644 src/it/copy-jars/src/main/java/Example_PlugIn.java create mode 100644 src/it/copy-jars/src/main/resources/plugins.config create mode 100644 src/it/copy-jars/verify.bsh create mode 100644 src/it/copy-to-subdirectory/pom.xml create mode 100644 src/it/copy-to-subdirectory/setup.bsh create mode 100644 src/it/copy-to-subdirectory/src/main/resources/plugins.config create mode 100644 src/it/copy-to-subdirectory/verify.bsh create mode 100644 src/it/delete-other-versions-configuration/pom.xml create mode 100644 src/it/delete-other-versions-configuration/setup.bsh create mode 100644 src/it/delete-other-versions-configuration/src/main/resources/plugins.config create mode 100644 src/it/delete-other-versions-configuration/verify.bsh create mode 100644 src/it/delete-other-versions-in-subdirectory/pom.xml create mode 100644 src/it/delete-other-versions-in-subdirectory/setup.bsh create mode 100644 src/it/delete-other-versions-in-subdirectory/src/main/resources/plugins.config create mode 100644 src/it/delete-other-versions-in-subdirectory/verify.bsh create mode 100644 src/it/delete-other-versions-policy/pom.xml create mode 100644 src/it/delete-other-versions-policy/setup.bsh create mode 100644 src/it/delete-other-versions-policy/src/main/resources/plugins.config create mode 100644 src/it/delete-other-versions-policy/verify.bsh create mode 100644 src/it/delete-other-versions-property-false/pom.xml create mode 100644 src/it/delete-other-versions-property-false/setup.bsh create mode 100644 src/it/delete-other-versions-property-false/src/main/resources/plugins.config create mode 100644 src/it/delete-other-versions-property-false/verify.bsh create mode 100644 src/it/delete-other-versions-property-true/pom.xml create mode 100644 src/it/delete-other-versions-property-true/setup.bsh create mode 100644 src/it/delete-other-versions-property-true/src/main/resources/plugins.config create mode 100644 src/it/delete-other-versions-property-true/verify.bsh create mode 100644 src/it/do-not-delete-natives/pom.xml create mode 100644 src/it/do-not-delete-natives/setup.bsh create mode 100644 src/it/do-not-delete-natives/src/main/resources/plugins.config create mode 100644 src/it/do-not-delete-natives/verify.bsh create mode 100644 src/it/exclusions/dependency/pom.xml create mode 100644 src/it/exclusions/dependency/src/main/resources/empty.txt create mode 100644 src/it/exclusions/excluded/pom.xml create mode 100644 src/it/exclusions/excluded/src/main/resources/empty.txt create mode 100644 src/it/exclusions/pom.xml create mode 100644 src/it/exclusions/setup.bsh create mode 100644 src/it/exclusions/to-copy/pom.xml create mode 100644 src/it/exclusions/to-copy/src/main/resources/empty.txt create mode 100644 src/it/exclusions/verify.bsh create mode 100644 src/it/handle-missing-version-numbers/pom.xml create mode 100644 src/it/handle-missing-version-numbers/setup.bsh create mode 100644 src/it/handle-missing-version-numbers/src/main/resources/empty.txt create mode 100644 src/it/handle-missing-version-numbers/verify.bsh create mode 100644 src/it/ignore-dependencies/pom.xml create mode 100644 src/it/ignore-dependencies/setup.bsh create mode 100644 src/it/ignore-dependencies/src/main/resources/plugins.config create mode 100644 src/it/ignore-dependencies/verify.bsh create mode 100644 src/it/install-from-local-repo/only-local/pom.xml create mode 100644 src/it/install-from-local-repo/only-local/src/main/resources/empty.txt create mode 100644 src/it/install-from-local-repo/pom.xml create mode 100644 src/it/install-from-local-repo/setup.bsh create mode 100644 src/it/install-from-local-repo/to-copy/pom.xml create mode 100644 src/it/install-from-local-repo/to-copy/src/main/resources/empty.txt create mode 100644 src/it/install-from-local-repo/verify.bsh create mode 100644 src/it/lib.bsh create mode 100644 src/it/missing-property/pom.xml create mode 100644 src/it/missing-property/verify.bsh create mode 100644 src/it/no-nag/pom.xml create mode 100644 src/it/no-nag/verify.bsh create mode 100644 src/it/settings.xml create mode 100644 src/it/skip-copy-jars/pom.xml create mode 100644 src/it/skip-copy-jars/verify.bsh create mode 100644 src/it/skip-optional/pom.xml create mode 100644 src/it/skip-optional/setup.bsh create mode 100644 src/it/skip-optional/verify.bsh diff --git a/src/it/copy-jars/pom.xml b/src/it/copy-jars/pom.xml new file mode 100644 index 0000000..1dd19e8 --- /dev/null +++ b/src/it/copy-jars/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo + + + + junit + junit + 4.8.1 + test + + + net.imagej + ij + 1.48s + + + + + ${project.basedir}/target/ImageJ.app/ + UTF-8 + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + install-artifact + install + + install-artifact + + + ${project.basedir}/target/Other.app/ + ${project.groupId}:${project.artifactId}:${project.version} + + + + + + + diff --git a/src/it/copy-jars/setup.bsh b/src/it/copy-jars/setup.bsh new file mode 100644 index 0000000..ec1d1af --- /dev/null +++ b/src/it/copy-jars/setup.bsh @@ -0,0 +1,34 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); +touchFile(new File(plugins, "Example_PlugIn-0.9.0-obsolete.jar")); diff --git a/src/it/copy-jars/src/main/java/Example_PlugIn.java b/src/it/copy-jars/src/main/java/Example_PlugIn.java new file mode 100644 index 0000000..fd03b24 --- /dev/null +++ b/src/it/copy-jars/src/main/java/Example_PlugIn.java @@ -0,0 +1,44 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ + +import ij.IJ; +import ij.plugin.PlugIn; + +/** + * A very simple plugin for testing purposes. + * + * @author Johannes Schindelin + */ +public class Example_PlugIn implements PlugIn { + public void run(final String arg) { + IJ.log("Hello, World!"); + } +} diff --git a/src/it/copy-jars/src/main/resources/plugins.config b/src/it/copy-jars/src/main/resources/plugins.config new file mode 100644 index 0000000..1d5b95d --- /dev/null +++ b/src/it/copy-jars/src/main/resources/plugins.config @@ -0,0 +1,31 @@ +### +# #%L +# ImageJ software for multidimensional image processing and analysis. +# %% +# Copyright (C) 2012 - 2016 Board of Regents of the University of +# Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +# Institute of Molecular Cell Biology and Genetics. +# %% +# 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. +# +# 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 COPYRIGHT HOLDERS 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. +# #L% +### +Example, "Plug In", Example_PlugIn diff --git a/src/it/copy-jars/verify.bsh b/src/it/copy-jars/verify.bsh new file mode 100644 index 0000000..296202a --- /dev/null +++ b/src/it/copy-jars/verify.bsh @@ -0,0 +1,41 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +assertTrue("Should exist: " + plugin, plugin.exists()); + +// install-artifact must not copy test scope dependencies +junit = new File(ijDir, "../Other.app/jars/junit-4.8.1.jar"); +assertTrue("Should not exist: " + junit, !junit.exists()); + +// but it must copy the ij dependency +ij = new File(ijDir, "../Other.app/jars/ij-1.48s.jar"); +assertTrue("ImageJ 1.x was not copied: " + ij, ij.exists()); diff --git a/src/it/copy-to-subdirectory/pom.xml b/src/it/copy-to-subdirectory/pom.xml new file mode 100644 index 0000000..484928c --- /dev/null +++ b/src/it/copy-to-subdirectory/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo + + + + net.imagej + ij + 1.48s + + + + + ${project.basedir}/target/ImageJ.app/ + plugins/Test/Directory/ + UTF-8 + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + install-artifact + install + + install-artifact + + + ${project.basedir}/target/Other.app/ + jars/Subdirectory/ + ${project.groupId}:${project.artifactId}:${project.version} + + + + + + + diff --git a/src/it/copy-to-subdirectory/setup.bsh b/src/it/copy-to-subdirectory/setup.bsh new file mode 100644 index 0000000..754ebb3 --- /dev/null +++ b/src/it/copy-to-subdirectory/setup.bsh @@ -0,0 +1,33 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); diff --git a/src/it/copy-to-subdirectory/src/main/resources/plugins.config b/src/it/copy-to-subdirectory/src/main/resources/plugins.config new file mode 100644 index 0000000..9921c16 --- /dev/null +++ b/src/it/copy-to-subdirectory/src/main/resources/plugins.config @@ -0,0 +1,31 @@ +### +# #%L +# ImageJ software for multidimensional image processing and analysis. +# %% +# Copyright (C) 2012 - 2016 Board of Regents of the University of +# Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +# Institute of Molecular Cell Biology and Genetics. +# %% +# 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. +# +# 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 COPYRIGHT HOLDERS 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. +# #L% +### +# Intentionally left blank diff --git a/src/it/copy-to-subdirectory/verify.bsh b/src/it/copy-to-subdirectory/verify.bsh new file mode 100644 index 0000000..db129e6 --- /dev/null +++ b/src/it/copy-to-subdirectory/verify.bsh @@ -0,0 +1,39 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +subdirectory = new File(plugins, "Test/Directory/"); +assertTrue("Should exist: " + subdirectory, subdirectory.exists()); +jar = new File(subdirectory, "Example_PlugIn-1.0.0-SNAPSHOT.jar"); +assertTrue("Should exist: " + jar, jar.exists()); + +subdirectoryPlugin = new File(ijDir, "../Other.app/jars/Subdirectory/Example_PlugIn-1.0.0-SNAPSHOT.jar"); +assertTrue("Should exist: " + subdirectoryPlugin, subdirectoryPlugin.exists()); diff --git a/src/it/delete-other-versions-configuration/pom.xml b/src/it/delete-other-versions-configuration/pom.xml new file mode 100644 index 0000000..cbaed5b --- /dev/null +++ b/src/it/delete-other-versions-configuration/pom.xml @@ -0,0 +1,67 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo + + + ${project.basedir}/target/ImageJ.app/ + UTF-8 + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + false + + + + + + + diff --git a/src/it/delete-other-versions-configuration/setup.bsh b/src/it/delete-other-versions-configuration/setup.bsh new file mode 100644 index 0000000..fd547d8 --- /dev/null +++ b/src/it/delete-other-versions-configuration/setup.bsh @@ -0,0 +1,34 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); +touchFile(new File(plugins, "Example_PlugIn-1.1.0.jar")); diff --git a/src/it/delete-other-versions-configuration/src/main/resources/plugins.config b/src/it/delete-other-versions-configuration/src/main/resources/plugins.config new file mode 100644 index 0000000..9921c16 --- /dev/null +++ b/src/it/delete-other-versions-configuration/src/main/resources/plugins.config @@ -0,0 +1,31 @@ +### +# #%L +# ImageJ software for multidimensional image processing and analysis. +# %% +# Copyright (C) 2012 - 2016 Board of Regents of the University of +# Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +# Institute of Molecular Cell Biology and Genetics. +# %% +# 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. +# +# 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 COPYRIGHT HOLDERS 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. +# #L% +### +# Intentionally left blank diff --git a/src/it/delete-other-versions-configuration/verify.bsh b/src/it/delete-other-versions-configuration/verify.bsh new file mode 100644 index 0000000..e39f7bd --- /dev/null +++ b/src/it/delete-other-versions-configuration/verify.bsh @@ -0,0 +1,35 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +assertTrue("Should not exist: " + plugin, !plugin.exists()); +otherVersion = new File(plugins, "Example_PlugIn-1.1.0.jar"); +assertTrue("Should exist: " + otherVersion, otherVersion.exists()); diff --git a/src/it/delete-other-versions-in-subdirectory/pom.xml b/src/it/delete-other-versions-in-subdirectory/pom.xml new file mode 100644 index 0000000..5c2d78a --- /dev/null +++ b/src/it/delete-other-versions-in-subdirectory/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo + + + ${project.basedir}/target/ImageJ.app/ + plugins/Test2/ + UTF-8 + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + always + + + + copy-jars + install + + copy-jars + + + + + + + diff --git a/src/it/delete-other-versions-in-subdirectory/setup.bsh b/src/it/delete-other-versions-in-subdirectory/setup.bsh new file mode 100644 index 0000000..43a2b63 --- /dev/null +++ b/src/it/delete-other-versions-in-subdirectory/setup.bsh @@ -0,0 +1,40 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); +subdir = new File(plugins, "Test"); +subdir.mkdirs(); + +subdir2 = new File(plugins, "Test2"); +subdir2.mkdirs(); + +touchFile(new File(subdir, "Example_PlugIn-0.9.0-obsolete.jar")); diff --git a/src/it/delete-other-versions-in-subdirectory/src/main/resources/plugins.config b/src/it/delete-other-versions-in-subdirectory/src/main/resources/plugins.config new file mode 100644 index 0000000..9921c16 --- /dev/null +++ b/src/it/delete-other-versions-in-subdirectory/src/main/resources/plugins.config @@ -0,0 +1,31 @@ +### +# #%L +# ImageJ software for multidimensional image processing and analysis. +# %% +# Copyright (C) 2012 - 2016 Board of Regents of the University of +# Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +# Institute of Molecular Cell Biology and Genetics. +# %% +# 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. +# +# 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 COPYRIGHT HOLDERS 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. +# #L% +### +# Intentionally left blank diff --git a/src/it/delete-other-versions-in-subdirectory/verify.bsh b/src/it/delete-other-versions-in-subdirectory/verify.bsh new file mode 100644 index 0000000..1a9127b --- /dev/null +++ b/src/it/delete-other-versions-in-subdirectory/verify.bsh @@ -0,0 +1,39 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +testSubdir = new File(plugins, "Test/"); +obsolete = new File(testSubdir, "Example_PlugIn-0.9.0-obsolete.jar"); +assertTrue("Should not exist: " + obsolete, !obsolete.exists()); + +testSubdir2 = new File(plugins, "Test2"); +jar = new File(testSubdir2, "Example_PlugIn-1.0.0-SNAPSHOT.jar"); +assertTrue("Should exist: " + jar, jar.exists()); diff --git a/src/it/delete-other-versions-policy/pom.xml b/src/it/delete-other-versions-policy/pom.xml new file mode 100644 index 0000000..dd243cd --- /dev/null +++ b/src/it/delete-other-versions-policy/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo + + + ${project.basedir}/target/ImageJ.app/ + UTF-8 + always + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + install-artifact + install + + install-artifact + + + ${project.basedir}/target/Other.app/ + ${project.groupId}:${project.artifactId}:${project.version} + older + + + + + + + diff --git a/src/it/delete-other-versions-policy/setup.bsh b/src/it/delete-other-versions-policy/setup.bsh new file mode 100644 index 0000000..d42626c --- /dev/null +++ b/src/it/delete-other-versions-policy/setup.bsh @@ -0,0 +1,44 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +// copy-jars +if (!plugins.exists()) plugins.mkdirs(); +touchFile(new File(plugins, "Example_PlugIn-1.1.0.jar")); + +// install-artifact +other = new File(basedir, "target/Other.app/"); +if (!other.exists()) other.mkdirs(); + +otherPlugins = new File(other, "plugins/"); +if (!otherPlugins.exists()) otherPlugins.mkdirs(); + +touchFile(new File(otherPlugins, "Example_PlugIn-2.1.0.jar")); diff --git a/src/it/delete-other-versions-policy/src/main/resources/plugins.config b/src/it/delete-other-versions-policy/src/main/resources/plugins.config new file mode 100644 index 0000000..9921c16 --- /dev/null +++ b/src/it/delete-other-versions-policy/src/main/resources/plugins.config @@ -0,0 +1,31 @@ +### +# #%L +# ImageJ software for multidimensional image processing and analysis. +# %% +# Copyright (C) 2012 - 2016 Board of Regents of the University of +# Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +# Institute of Molecular Cell Biology and Genetics. +# %% +# 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. +# +# 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 COPYRIGHT HOLDERS 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. +# #L% +### +# Intentionally left blank diff --git a/src/it/delete-other-versions-policy/verify.bsh b/src/it/delete-other-versions-policy/verify.bsh new file mode 100644 index 0000000..9690d09 --- /dev/null +++ b/src/it/delete-other-versions-policy/verify.bsh @@ -0,0 +1,52 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +// copy-jars +assertTrue("Should exist: " + plugin, plugin.exists()); +newer = new File(plugins, "Example_PlugIn-1.1.0.jar"); +assertTrue("Should not exist: " + newer, !newer.exists()); + +// install-artifact +other = new File(basedir, "target/Other.app/"); +assertTrue("Should exist: "+ other, other.exists()); + +otherPlugins = new File(other, "plugins/"); +assertTrue("Should exist: "+ otherPlugins, otherPlugins.exists()); + +newer = new File(otherPlugins, "Example_PlugIn-2.1.0.jar"); +assertTrue("Should exist: " + newer, newer.exists()); +toInstall = new File(otherPlugins, "Example_PlugIn-1.0.0-SNAPSHOT.jar"); +assertTrue("Should not exist: " + newer, !toInstall.exists()); + +buildLog = readFile(new File(basedir, "build.log")); +assertTrue("Found other version that is incompatible':\n" + buildLog, + buildLog.contains("Found other version that is incompatible")); diff --git a/src/it/delete-other-versions-property-false/pom.xml b/src/it/delete-other-versions-property-false/pom.xml new file mode 100644 index 0000000..d88cf85 --- /dev/null +++ b/src/it/delete-other-versions-property-false/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo + + + ${project.basedir}/target/ImageJ.app/ + UTF-8 + false + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + + + + diff --git a/src/it/delete-other-versions-property-false/setup.bsh b/src/it/delete-other-versions-property-false/setup.bsh new file mode 100644 index 0000000..fd547d8 --- /dev/null +++ b/src/it/delete-other-versions-property-false/setup.bsh @@ -0,0 +1,34 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); +touchFile(new File(plugins, "Example_PlugIn-1.1.0.jar")); diff --git a/src/it/delete-other-versions-property-false/src/main/resources/plugins.config b/src/it/delete-other-versions-property-false/src/main/resources/plugins.config new file mode 100644 index 0000000..9921c16 --- /dev/null +++ b/src/it/delete-other-versions-property-false/src/main/resources/plugins.config @@ -0,0 +1,31 @@ +### +# #%L +# ImageJ software for multidimensional image processing and analysis. +# %% +# Copyright (C) 2012 - 2016 Board of Regents of the University of +# Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +# Institute of Molecular Cell Biology and Genetics. +# %% +# 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. +# +# 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 COPYRIGHT HOLDERS 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. +# #L% +### +# Intentionally left blank diff --git a/src/it/delete-other-versions-property-false/verify.bsh b/src/it/delete-other-versions-property-false/verify.bsh new file mode 100644 index 0000000..aa31e3f --- /dev/null +++ b/src/it/delete-other-versions-property-false/verify.bsh @@ -0,0 +1,35 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +assertTrue("Should exist: " + plugin, plugin.exists()); +otherVersion = new File(plugins, "Example_PlugIn-1.1.0.jar"); +assertTrue("Should exist: " + otherVersion, otherVersion.exists()); diff --git a/src/it/delete-other-versions-property-true/pom.xml b/src/it/delete-other-versions-property-true/pom.xml new file mode 100644 index 0000000..1613cd6 --- /dev/null +++ b/src/it/delete-other-versions-property-true/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo + + + ${project.basedir}/target/ImageJ.app/ + UTF-8 + true + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + + + + diff --git a/src/it/delete-other-versions-property-true/setup.bsh b/src/it/delete-other-versions-property-true/setup.bsh new file mode 100644 index 0000000..fd547d8 --- /dev/null +++ b/src/it/delete-other-versions-property-true/setup.bsh @@ -0,0 +1,34 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); +touchFile(new File(plugins, "Example_PlugIn-1.1.0.jar")); diff --git a/src/it/delete-other-versions-property-true/src/main/resources/plugins.config b/src/it/delete-other-versions-property-true/src/main/resources/plugins.config new file mode 100644 index 0000000..9921c16 --- /dev/null +++ b/src/it/delete-other-versions-property-true/src/main/resources/plugins.config @@ -0,0 +1,31 @@ +### +# #%L +# ImageJ software for multidimensional image processing and analysis. +# %% +# Copyright (C) 2012 - 2016 Board of Regents of the University of +# Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +# Institute of Molecular Cell Biology and Genetics. +# %% +# 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. +# +# 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 COPYRIGHT HOLDERS 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. +# #L% +### +# Intentionally left blank diff --git a/src/it/delete-other-versions-property-true/verify.bsh b/src/it/delete-other-versions-property-true/verify.bsh new file mode 100644 index 0000000..e39f7bd --- /dev/null +++ b/src/it/delete-other-versions-property-true/verify.bsh @@ -0,0 +1,35 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +assertTrue("Should not exist: " + plugin, !plugin.exists()); +otherVersion = new File(plugins, "Example_PlugIn-1.1.0.jar"); +assertTrue("Should exist: " + otherVersion, otherVersion.exists()); diff --git a/src/it/do-not-delete-natives/pom.xml b/src/it/do-not-delete-natives/pom.xml new file mode 100644 index 0000000..0d5c9b7 --- /dev/null +++ b/src/it/do-not-delete-natives/pom.xml @@ -0,0 +1,67 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test if LWJGL natives-* files are kept + + + ${project.basedir}/target/ImageJ.app/ + UTF-8 + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + always + + + + copy-jars + install + + copy-jars + + + + + + + diff --git a/src/it/do-not-delete-natives/setup.bsh b/src/it/do-not-delete-natives/setup.bsh new file mode 100644 index 0000000..99863e9 --- /dev/null +++ b/src/it/do-not-delete-natives/setup.bsh @@ -0,0 +1,34 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); +touchFile(new File(plugins, "Example_PlugIn-0.9.0-natives-linux.jar")); diff --git a/src/it/do-not-delete-natives/src/main/resources/plugins.config b/src/it/do-not-delete-natives/src/main/resources/plugins.config new file mode 100644 index 0000000..9921c16 --- /dev/null +++ b/src/it/do-not-delete-natives/src/main/resources/plugins.config @@ -0,0 +1,31 @@ +### +# #%L +# ImageJ software for multidimensional image processing and analysis. +# %% +# Copyright (C) 2012 - 2016 Board of Regents of the University of +# Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +# Institute of Molecular Cell Biology and Genetics. +# %% +# 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. +# +# 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 COPYRIGHT HOLDERS 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. +# #L% +### +# Intentionally left blank diff --git a/src/it/do-not-delete-natives/verify.bsh b/src/it/do-not-delete-natives/verify.bsh new file mode 100644 index 0000000..903f660 --- /dev/null +++ b/src/it/do-not-delete-natives/verify.bsh @@ -0,0 +1,35 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +assertTrue("Should exist: " + plugin, plugin.exists()); +natives = new File(plugins, "Example_PlugIn-0.9.0-natives-linux.jar"); +assertTrue("Should exist: " + natives, natives.exists()); diff --git a/src/it/exclusions/dependency/pom.xml b/src/it/exclusions/dependency/pom.xml new file mode 100644 index 0000000..ca6b4d4 --- /dev/null +++ b/src/it/exclusions/dependency/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + org.apache.maven.plugin.my.unit + dependency + 1.0.0-SNAPSHOT + jar + An example artifact with a dependency to be excluded via <exclusions> + + + + ${project.groupId} + excluded + ${project.version} + + + diff --git a/src/it/exclusions/dependency/src/main/resources/empty.txt b/src/it/exclusions/dependency/src/main/resources/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/it/exclusions/excluded/pom.xml b/src/it/exclusions/excluded/pom.xml new file mode 100644 index 0000000..92040bc --- /dev/null +++ b/src/it/exclusions/excluded/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + excluded + 1.0.0-SNAPSHOT + jar + An example artifact to exclude via <exclusions> + diff --git a/src/it/exclusions/excluded/src/main/resources/empty.txt b/src/it/exclusions/excluded/src/main/resources/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/it/exclusions/pom.xml b/src/it/exclusions/pom.xml new file mode 100644 index 0000000..1f683a7 --- /dev/null +++ b/src/it/exclusions/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + exclusions + 1.0.0-SNAPSHOT + pom + Top-level project for testing exclusions + + + UTF-8 + + + + excluded + dependency + to-copy + + diff --git a/src/it/exclusions/setup.bsh b/src/it/exclusions/setup.bsh new file mode 100644 index 0000000..754ebb3 --- /dev/null +++ b/src/it/exclusions/setup.bsh @@ -0,0 +1,33 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); diff --git a/src/it/exclusions/to-copy/pom.xml b/src/it/exclusions/to-copy/pom.xml new file mode 100644 index 0000000..ef389b6 --- /dev/null +++ b/src/it/exclusions/to-copy/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + to-copy + 1.0.0-SNAPSHOT + jar + An example artifact to test support for <exclusions> + + + ${project.basedir}/../target/ImageJ.app/ + + + + + ${project.groupId} + dependency + ${project.version} + + + ${project.groupId} + excluded + + + + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + + + + diff --git a/src/it/exclusions/to-copy/src/main/resources/empty.txt b/src/it/exclusions/to-copy/src/main/resources/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/it/exclusions/verify.bsh b/src/it/exclusions/verify.bsh new file mode 100644 index 0000000..b72b930 --- /dev/null +++ b/src/it/exclusions/verify.bsh @@ -0,0 +1,36 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +jars = new File(ijDir, "jars"); +assertTrue("Does not have to-copy.jar", new File(jars, "to-copy-1.0.0-SNAPSHOT.jar").exists()); +assertTrue("Does not have dependency.jar", new File(jars, "dependency-1.0.0-SNAPSHOT.jar").exists()); +assertTrue("Has excluded.jar", !new File(jars, "excluded-1.0.0-SNAPSHOT.jar").exists()); diff --git a/src/it/handle-missing-version-numbers/pom.xml b/src/it/handle-missing-version-numbers/pom.xml new file mode 100644 index 0000000..d719f44 --- /dev/null +++ b/src/it/handle-missing-version-numbers/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + missing-version-number + 1.0.0 + jar + An example artifact to test support for missing version numbers + + + ${project.basedir}/target/ImageJ.app/ + older + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + + + + diff --git a/src/it/handle-missing-version-numbers/setup.bsh b/src/it/handle-missing-version-numbers/setup.bsh new file mode 100644 index 0000000..7dd2d07 --- /dev/null +++ b/src/it/handle-missing-version-numbers/setup.bsh @@ -0,0 +1,35 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +jars = new File(ijDir, "jars"); +if (!jars.exists()) jars.mkdirs(); +touchFile(new File(jars, "missing-version-number.jar")); diff --git a/src/it/handle-missing-version-numbers/src/main/resources/empty.txt b/src/it/handle-missing-version-numbers/src/main/resources/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/it/handle-missing-version-numbers/verify.bsh b/src/it/handle-missing-version-numbers/verify.bsh new file mode 100644 index 0000000..fa024c9 --- /dev/null +++ b/src/it/handle-missing-version-numbers/verify.bsh @@ -0,0 +1,39 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +jars = new File(ijDir, "jars"); +assertTrue("Has missing-version-number-1.0.0.jar", + !new File(jars, "missing-version-number-1.0.0.jar").exists()); + +buildLog = readFile(new File(basedir, "build.log")); +assertTrue("Should contain 'Impenetrable version suffix':\n" + buildLog, + buildLog.contains("Impenetrable version suffix")); diff --git a/src/it/ignore-dependencies/pom.xml b/src/it/ignore-dependencies/pom.xml new file mode 100644 index 0000000..8cc5cec --- /dev/null +++ b/src/it/ignore-dependencies/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example artifact to test ignoring dependencies + + + ${project.basedir}/target/ImageJ.app/ + true + + + + + net.imagej + ij + 1.48s + + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + install-artifact + install + + install-artifact + + + ${project.basedir}/target/Other.app/ + ${project.groupId}:${project.artifactId}:${project.version} + true + + + + + + + diff --git a/src/it/ignore-dependencies/setup.bsh b/src/it/ignore-dependencies/setup.bsh new file mode 100644 index 0000000..754ebb3 --- /dev/null +++ b/src/it/ignore-dependencies/setup.bsh @@ -0,0 +1,33 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); diff --git a/src/it/ignore-dependencies/src/main/resources/plugins.config b/src/it/ignore-dependencies/src/main/resources/plugins.config new file mode 100644 index 0000000..1d5b95d --- /dev/null +++ b/src/it/ignore-dependencies/src/main/resources/plugins.config @@ -0,0 +1,31 @@ +### +# #%L +# ImageJ software for multidimensional image processing and analysis. +# %% +# Copyright (C) 2012 - 2016 Board of Regents of the University of +# Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck +# Institute of Molecular Cell Biology and Genetics. +# %% +# 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. +# +# 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 COPYRIGHT HOLDERS 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. +# #L% +### +Example, "Plug In", Example_PlugIn diff --git a/src/it/ignore-dependencies/verify.bsh b/src/it/ignore-dependencies/verify.bsh new file mode 100644 index 0000000..a103823 --- /dev/null +++ b/src/it/ignore-dependencies/verify.bsh @@ -0,0 +1,39 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +assertTrue("Should exist: " + plugin, plugin.exists()); + +ij = new File(ijDir, "jars/ij-1.48s.jar"); +assertTrue("Should not exist: " + ij, !ij.exists()); + +otherIJ = new File(ijDir, "../Other.app/jars/ij-1.48s.jar"); +assertTrue("Should not exist: " + otherIJ, !otherIJ.exists()); diff --git a/src/it/install-from-local-repo/only-local/pom.xml b/src/it/install-from-local-repo/only-local/pom.xml new file mode 100644 index 0000000..125bb7b --- /dev/null +++ b/src/it/install-from-local-repo/only-local/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + only-local + 1.0.0-SNAPSHOT + jar + An example artifact that is only available in the local repository + diff --git a/src/it/install-from-local-repo/only-local/src/main/resources/empty.txt b/src/it/install-from-local-repo/only-local/src/main/resources/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/it/install-from-local-repo/pom.xml b/src/it/install-from-local-repo/pom.xml new file mode 100644 index 0000000..515d67e --- /dev/null +++ b/src/it/install-from-local-repo/pom.xml @@ -0,0 +1,49 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + exclusions + 1.0.0-SNAPSHOT + pom + Top-level project for testing installing from local repository + + + UTF-8 + + + + only-local + to-copy + + diff --git a/src/it/install-from-local-repo/setup.bsh b/src/it/install-from-local-repo/setup.bsh new file mode 100644 index 0000000..754ebb3 --- /dev/null +++ b/src/it/install-from-local-repo/setup.bsh @@ -0,0 +1,33 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); diff --git a/src/it/install-from-local-repo/to-copy/pom.xml b/src/it/install-from-local-repo/to-copy/pom.xml new file mode 100644 index 0000000..78cd9b9 --- /dev/null +++ b/src/it/install-from-local-repo/to-copy/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + to-copy + 1.0.0-SNAPSHOT + jar + An example artifact to test support for local repositories + + + ${project.basedir}/../target/ImageJ.app/ + + + + + ${project.groupId} + only-local + ${project.version} + + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + install-artifact + install + + install-artifact + + + ${project.basedir}/../target/Other.app/ + ${project.groupId}:${project.artifactId}:${project.version} + + + + + + + diff --git a/src/it/install-from-local-repo/to-copy/src/main/resources/empty.txt b/src/it/install-from-local-repo/to-copy/src/main/resources/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/it/install-from-local-repo/verify.bsh b/src/it/install-from-local-repo/verify.bsh new file mode 100644 index 0000000..b620446 --- /dev/null +++ b/src/it/install-from-local-repo/verify.bsh @@ -0,0 +1,40 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +// copy-jars +jars = new File(ijDir, "jars"); +assertTrue("Should have to-copy.jar", new File(jars, "to-copy-1.0.0-SNAPSHOT.jar").exists()); +assertTrue("Should have only-local.jar", new File(jars, "only-local-1.0.0-SNAPSHOT.jar").exists()); + +// install-artifact +assertTrue("Should have to-copy.jar", new File(ijDir, "../Other.app/jars/to-copy-1.0.0-SNAPSHOT.jar").exists()); +assertTrue("Should have only-local.jar", new File(ijDir, "../Other.app/jars/only-local-1.0.0-SNAPSHOT.jar").exists()); diff --git a/src/it/lib.bsh b/src/it/lib.bsh new file mode 100644 index 0000000..0eb1e2c --- /dev/null +++ b/src/it/lib.bsh @@ -0,0 +1,73 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; + +assertTrue(message, condition) { + if (!condition) { + System.err.println(message); + throw new RuntimeException("Failure!"); + } +} + +assertLogContains(needle) { + buildLog = readFile(new File(basedir, "build.log")); + assertTrue("Should contain '" + needle + "':\n" + buildLog, + buildLog.contains(needle)); +} + +readFile(file) { + builder = new StringBuilder(); + reader = new BufferedReader(new FileReader(file)); + for (;;) { + line = reader.readLine(); + if (line == null) break; + builder.append("> ").append(line).append("\n"); + } + return builder.toString(); +} + +touchFile(file) { + if (file.exists()) { + file.setLastModified(System.currentTimeMillis()); + } else { + new FileWriter(file).close(); + } +} + +target = new File(basedir, "target"); +ijDir = new File(target, "ImageJ.app"); +plugins = new File(ijDir, "plugins"); +plugin = new File(plugins, "Example_PlugIn-1.0.0-SNAPSHOT.jar"); + +//assertTrue("Is a directory: " + target, target.isDirectory()); diff --git a/src/it/missing-property/pom.xml b/src/it/missing-property/pom.xml new file mode 100644 index 0000000..c86e6a2 --- /dev/null +++ b/src/it/missing-property/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo + + + UTF-8 + + + + + net.imagej + ij + 1.48s + + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + test + + copy-jars + + + + + + + diff --git a/src/it/missing-property/verify.bsh b/src/it/missing-property/verify.bsh new file mode 100644 index 0000000..d44844d --- /dev/null +++ b/src/it/missing-property/verify.bsh @@ -0,0 +1,37 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +assertTrue("Should not exist: " + ijDir, !ijDir.exists()); + +buildLog = readFile(new File(basedir, "build.log")); +assertTrue("Should contain 'Skipping copy-jars':\n" + buildLog, + buildLog.contains("Skipping copy-jars")); diff --git a/src/it/no-nag/pom.xml b/src/it/no-nag/pom.xml new file mode 100644 index 0000000..fecfcc2 --- /dev/null +++ b/src/it/no-nag/pom.xml @@ -0,0 +1,63 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Not_A_PlugIn + 1.0.0-SNAPSHOT + jar + An example project without ImageJ 1.x dependency to test the CopyJarsMojo + + + UTF-8 + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + test + + copy-jars + + + + + + + diff --git a/src/it/no-nag/verify.bsh b/src/it/no-nag/verify.bsh new file mode 100644 index 0000000..2c7c0ea --- /dev/null +++ b/src/it/no-nag/verify.bsh @@ -0,0 +1,37 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +assertTrue("Should not exist: " + ijDir, !ijDir.exists()); + +buildLog = readFile(new File(basedir, "build.log")); +assertTrue("Should not contain 'Skipping copy-jars':\n" + buildLog, + !buildLog.contains("Skipping copy-jars")); diff --git a/src/it/settings.xml b/src/it/settings.xml new file mode 100644 index 0000000..575e89b --- /dev/null +++ b/src/it/settings.xml @@ -0,0 +1,66 @@ + + + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + diff --git a/src/it/skip-copy-jars/pom.xml b/src/it/skip-copy-jars/pom.xml new file mode 100644 index 0000000..b26b2d9 --- /dev/null +++ b/src/it/skip-copy-jars/pom.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo + + + + net.imagej + ij + 1.48s + + + + + ${project.basedir}/target/ImageJ.app/ + UTF-8 + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + + + + diff --git a/src/it/skip-copy-jars/verify.bsh b/src/it/skip-copy-jars/verify.bsh new file mode 100644 index 0000000..d44844d --- /dev/null +++ b/src/it/skip-copy-jars/verify.bsh @@ -0,0 +1,37 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +assertTrue("Should not exist: " + ijDir, !ijDir.exists()); + +buildLog = readFile(new File(basedir, "build.log")); +assertTrue("Should contain 'Skipping copy-jars':\n" + buildLog, + buildLog.contains("Skipping copy-jars")); diff --git a/src/it/skip-optional/pom.xml b/src/it/skip-optional/pom.xml new file mode 100644 index 0000000..d1a2df9 --- /dev/null +++ b/src/it/skip-optional/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + Example_PlugIn + 1.0.0-SNAPSHOT + jar + An example ImageJ 1.x plugin to test imagej-maven-plugin's install-artifact goal + + + + net.imagej + ij + 1.48s + true + + + + + ${project.basedir}/target/ImageJ.app/ + UTF-8 + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + install-artifact + install + + install-artifact + + + ${project.groupId}:${project.artifactId}:${project.version} + + + + + + + diff --git a/src/it/skip-optional/setup.bsh b/src/it/skip-optional/setup.bsh new file mode 100644 index 0000000..754ebb3 --- /dev/null +++ b/src/it/skip-optional/setup.bsh @@ -0,0 +1,33 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +if (!plugins.exists()) plugins.mkdirs(); diff --git a/src/it/skip-optional/verify.bsh b/src/it/skip-optional/verify.bsh new file mode 100644 index 0000000..9010a36 --- /dev/null +++ b/src/it/skip-optional/verify.bsh @@ -0,0 +1,35 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +// it must copy the optional ij dependency +ij = new File(ijDir, "jars/ij-1.48s.jar"); +assertTrue("ImageJ 1.x was copied although optional: " + ij, !ij.exists()); From 667ce7b18515b85283703fe967029422e85cdf82 Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Wed, 8 Aug 2018 06:34:24 +0200 Subject: [PATCH 04/16] Update property names in integration tests --- src/it/copy-jars/pom.xml | 4 ++-- src/it/copy-to-subdirectory/pom.xml | 8 ++++---- src/it/delete-other-versions-configuration/pom.xml | 2 +- src/it/delete-other-versions-in-subdirectory/pom.xml | 4 ++-- src/it/delete-other-versions-policy/pom.xml | 6 +++--- src/it/delete-other-versions-property-false/pom.xml | 2 +- src/it/delete-other-versions-property-true/pom.xml | 2 +- src/it/do-not-delete-natives/pom.xml | 2 +- src/it/exclusions/to-copy/pom.xml | 2 +- src/it/handle-missing-version-numbers/pom.xml | 4 ++-- src/it/ignore-dependencies/pom.xml | 4 ++-- src/it/install-from-local-repo/to-copy/pom.xml | 4 ++-- src/it/skip-copy-jars/pom.xml | 2 +- src/it/skip-optional/pom.xml | 2 +- 14 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/it/copy-jars/pom.xml b/src/it/copy-jars/pom.xml index 1dd19e8..96262cb 100644 --- a/src/it/copy-jars/pom.xml +++ b/src/it/copy-jars/pom.xml @@ -53,7 +53,7 @@ - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 @@ -78,7 +78,7 @@ install-artifact - ${project.basedir}/target/Other.app/ + ${project.basedir}/target/Other.app/ ${project.groupId}:${project.artifactId}:${project.version} diff --git a/src/it/copy-to-subdirectory/pom.xml b/src/it/copy-to-subdirectory/pom.xml index 484928c..a366def 100644 --- a/src/it/copy-to-subdirectory/pom.xml +++ b/src/it/copy-to-subdirectory/pom.xml @@ -47,8 +47,8 @@ - ${project.basedir}/target/ImageJ.app/ - plugins/Test/Directory/ + ${project.basedir}/target/ImageJ.app/ + plugins/Test/Directory/ UTF-8 @@ -73,8 +73,8 @@ install-artifact - ${project.basedir}/target/Other.app/ - jars/Subdirectory/ + ${project.basedir}/target/Other.app/ + jars/Subdirectory/ ${project.groupId}:${project.artifactId}:${project.version} diff --git a/src/it/delete-other-versions-configuration/pom.xml b/src/it/delete-other-versions-configuration/pom.xml index cbaed5b..53e5f06 100644 --- a/src/it/delete-other-versions-configuration/pom.xml +++ b/src/it/delete-other-versions-configuration/pom.xml @@ -39,7 +39,7 @@ An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 diff --git a/src/it/delete-other-versions-in-subdirectory/pom.xml b/src/it/delete-other-versions-in-subdirectory/pom.xml index 5c2d78a..092377e 100644 --- a/src/it/delete-other-versions-in-subdirectory/pom.xml +++ b/src/it/delete-other-versions-in-subdirectory/pom.xml @@ -39,8 +39,8 @@ An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo - ${project.basedir}/target/ImageJ.app/ - plugins/Test2/ + ${project.basedir}/target/ImageJ.app/ + plugins/Test2/ UTF-8 diff --git a/src/it/delete-other-versions-policy/pom.xml b/src/it/delete-other-versions-policy/pom.xml index dd243cd..b1aea7a 100644 --- a/src/it/delete-other-versions-policy/pom.xml +++ b/src/it/delete-other-versions-policy/pom.xml @@ -39,9 +39,9 @@ An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 - always + always @@ -65,7 +65,7 @@ install-artifact - ${project.basedir}/target/Other.app/ + ${project.basedir}/target/Other.app/ ${project.groupId}:${project.artifactId}:${project.version} older diff --git a/src/it/delete-other-versions-property-false/pom.xml b/src/it/delete-other-versions-property-false/pom.xml index d88cf85..7d14c60 100644 --- a/src/it/delete-other-versions-property-false/pom.xml +++ b/src/it/delete-other-versions-property-false/pom.xml @@ -39,7 +39,7 @@ An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 false diff --git a/src/it/delete-other-versions-property-true/pom.xml b/src/it/delete-other-versions-property-true/pom.xml index 1613cd6..620a66f 100644 --- a/src/it/delete-other-versions-property-true/pom.xml +++ b/src/it/delete-other-versions-property-true/pom.xml @@ -39,7 +39,7 @@ An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 true diff --git a/src/it/do-not-delete-natives/pom.xml b/src/it/do-not-delete-natives/pom.xml index 0d5c9b7..506882e 100644 --- a/src/it/do-not-delete-natives/pom.xml +++ b/src/it/do-not-delete-natives/pom.xml @@ -39,7 +39,7 @@ An example ImageJ 1.x plugin to test if LWJGL natives-* files are kept - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 diff --git a/src/it/exclusions/to-copy/pom.xml b/src/it/exclusions/to-copy/pom.xml index ef389b6..a809cfe 100644 --- a/src/it/exclusions/to-copy/pom.xml +++ b/src/it/exclusions/to-copy/pom.xml @@ -40,7 +40,7 @@ An example artifact to test support for <exclusions> - ${project.basedir}/../target/ImageJ.app/ + ${project.basedir}/../target/ImageJ.app/ diff --git a/src/it/handle-missing-version-numbers/pom.xml b/src/it/handle-missing-version-numbers/pom.xml index d719f44..a2e8f27 100644 --- a/src/it/handle-missing-version-numbers/pom.xml +++ b/src/it/handle-missing-version-numbers/pom.xml @@ -40,8 +40,8 @@ An example artifact to test support for missing version numbers - ${project.basedir}/target/ImageJ.app/ - older + ${project.basedir}/target/ImageJ.app/ + older diff --git a/src/it/ignore-dependencies/pom.xml b/src/it/ignore-dependencies/pom.xml index 8cc5cec..4a319a6 100644 --- a/src/it/ignore-dependencies/pom.xml +++ b/src/it/ignore-dependencies/pom.xml @@ -40,7 +40,7 @@ An example artifact to test ignoring dependencies - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ true @@ -73,7 +73,7 @@ install-artifact - ${project.basedir}/target/Other.app/ + ${project.basedir}/target/Other.app/ ${project.groupId}:${project.artifactId}:${project.version} true diff --git a/src/it/install-from-local-repo/to-copy/pom.xml b/src/it/install-from-local-repo/to-copy/pom.xml index 78cd9b9..99616e5 100644 --- a/src/it/install-from-local-repo/to-copy/pom.xml +++ b/src/it/install-from-local-repo/to-copy/pom.xml @@ -40,7 +40,7 @@ An example artifact to test support for local repositories - ${project.basedir}/../target/ImageJ.app/ + ${project.basedir}/../target/ImageJ.app/ @@ -72,7 +72,7 @@ install-artifact - ${project.basedir}/../target/Other.app/ + ${project.basedir}/../target/Other.app/ ${project.groupId}:${project.artifactId}:${project.version} diff --git a/src/it/skip-copy-jars/pom.xml b/src/it/skip-copy-jars/pom.xml index b26b2d9..abff3d2 100644 --- a/src/it/skip-copy-jars/pom.xml +++ b/src/it/skip-copy-jars/pom.xml @@ -47,7 +47,7 @@ - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 diff --git a/src/it/skip-optional/pom.xml b/src/it/skip-optional/pom.xml index d1a2df9..6cd4a2d 100644 --- a/src/it/skip-optional/pom.xml +++ b/src/it/skip-optional/pom.xml @@ -48,7 +48,7 @@ - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 From 08e59f099395e46495e9e44cea2ea033f053876f Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Mon, 6 Aug 2018 07:25:50 +0200 Subject: [PATCH 05/16] Add imagej-maven-plugin's lifecycle mapping --- .../META-INF/m2e/lifecycle-mapping-metadata.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml index 32834d0..81fdb7b 100644 --- a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml +++ b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml @@ -51,5 +51,15 @@ + + + + copy-jars + + + + + + From 5b3d2059cf83867e151c633870dcfb48b8994d62 Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Mon, 6 Aug 2018 07:40:21 +0200 Subject: [PATCH 06/16] Merge POMs Also bumps the parent POM to the more recent version of pom-scijava of imagej-maven-plugin. Some dependencies have to be bumped to newer versions as well, which also leads to some minor changes wrt. enforcer rules. --- pom.xml | 206 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 141 insertions(+), 65 deletions(-) diff --git a/pom.xml b/pom.xml index 9e72269..622d338 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.scijava pom-scijava - 9.0.0 + 17.1.1 @@ -15,7 +15,12 @@ SciJava plugin for Maven A plugin for managing SciJava-based projects. + https://github.com/scijava/scijava-maven-plugin 2014 + + SciJava + http://www.scijava.org/ + Simplified BSD License @@ -37,6 +42,18 @@ maintainer + + stelfrich + Stefan Helfrich + http://imagej.net/User:Stelfrich + + developer + debugger + reviewer + support + maintainer + + @@ -52,18 +69,43 @@ + + + ImageJ Forum + http://forum.imagej.net/ + + + scm:git:git://github.com/scijava/scijava-maven-plugin scm:git:git@github.com:scijava/scijava-maven-plugin HEAD https://github.com/scijava/scijava-maven-plugin + + GitHub Issues + https://github.com/scijava/scijava-maven-plugin/issues + + + Travis CI + https://travis-ci.org/scijava/scijava-maven-plugin + 1.3.1 + bsd_2 + Board of Regents of the University of +Wisconsin-Madison, Broad Institute of MIT and Harvard, Max Planck +Institute of Molecular Cell Biology and Genetics, University of +Konstanz, and KNIME GmbH. + SciJava Common shared library for SciJava software. + 1.8 + 1.6 3.0 2.2.1 2.2 + org.scijava.maven + 2.66.0 @@ -90,48 +132,6 @@
- - org.apache.maven - maven-artifact - ${maven2.version} - - - org.codehaus.plexus - plexus-utils - - - - - org.apache.maven - maven-project - ${maven2.version} - - - org.codehaus.plexus - plexus-interpolation - - - org.codehaus.plexus - plexus-utils - - - org.apache.maven - maven-artifact-manager - - - org.apache.maven - maven-model - - - org.apache.maven - maven-settings - - - classworlds - classworlds - - - org.apache.maven maven-plugin-api @@ -166,13 +166,57 @@ org.apache.maven.plugin-tools maven-plugin-annotations - 3.3 + 3.5 junit junit test + + + org.apache.maven + maven-artifact + ${maven.version} + + + org.apache.maven + maven-compat + ${maven.version} + + + org.apache.maven + maven-model + ${maven.version} + + + + org.apache.maven.shared + maven-artifact-transfer + 0.9.1 + + + org.apache.maven.shared + maven-common-artifact-filters + 3.0.1 + + + + org.codehaus.plexus + plexus-interpolation + 1.24 + + + org.codehaus.plexus + plexus-utils + 3.1.0 + + + + org.scijava + scijava-common + ${scijava-common.version} + @@ -205,6 +249,18 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + 1.0 + + + org.codehaus.mojo + extra-enforcer-rules + 1.0-beta-9 + + + @@ -212,26 +268,19 @@ maven-enforcer-plugin - + - - - maven-artifact - - org/apache/maven/artifact/* - - - - maven-project - - org/apache/maven/project/* - - - - + + org/apache/maven/artifact/* + + org/apache/maven/project/* + + true + true + @@ -253,13 +302,40 @@ - org.codehaus.mojo - license-maven-plugin + maven-invoker-plugin + 1.8 - bsd_2 - Board of Regents of the University of -Wisconsin-Madison. + + true + true + + ${project.version} + + src/it + ${project.build.directory}/it + + */pom.xml + + src/it/settings.xml + ${project.build.directory}/local-repo + setup.bsh + verify.bsh + + install + + + + integration-test + + install + run + + + + + + maven-release-plugin From 80176ca271c980b60aace15a6bdf1c3878acc27b Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Tue, 7 Aug 2018 07:08:04 +0200 Subject: [PATCH 07/16] Replace Javadoc descriptor with annotation This changes is required due the bump of pom-scijava in the previous commit. --- .../org/scijava/maven/plugin/VerifyNoSnapshotsMojo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/scijava/maven/plugin/VerifyNoSnapshotsMojo.java b/src/main/java/org/scijava/maven/plugin/VerifyNoSnapshotsMojo.java index 14bb08a..a94c4ff 100644 --- a/src/main/java/org/scijava/maven/plugin/VerifyNoSnapshotsMojo.java +++ b/src/main/java/org/scijava/maven/plugin/VerifyNoSnapshotsMojo.java @@ -39,6 +39,8 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; @@ -57,10 +59,8 @@ * are specified. * *

- * - * @goal verify-no-snapshots - * @phase validate */ +@Mojo(name = "verify-no-snapshots", defaultPhase = LifecyclePhase.VALIDATE) public class VerifyNoSnapshotsMojo extends AbstractMojo { // -- Parameters -- From 3e7c27c0867002562ed79baf28849ac02bac4e85 Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Thu, 9 Aug 2018 07:22:11 +0200 Subject: [PATCH 08/16] Merge READMEs --- README.md | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8053c91..643e4a3 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,21 @@ $ mvn scijava:help [INFO] SciJava plugin for Maven 0.5.0 A plugin for managing SciJava-based projects. -This plugin has 5 goals: +This plugin has 7 goals: scijava:bump Bumps dependency and parent versions in SciJava projects. +scijava:copy-jars + Copies .jar artifacts and their dependencies into a SciJava application + directory structure. ImageJ 1.x plugins (identified by containing a + plugins.config file) get copied to the plugins/ subdirectory and all other + .jar files to jars/. However, you can override this decision by setting the + scijava.app.subdirectory property to a specific subdirectory. It expects the + location of the SciJava application directory to be specified in the + scijava.app.directory property (which can be set on the Maven command-line). + If said property is not set, the copy-jars goal is skipped. + scijava:eclipse-helper Runs the annotation processor of the scijava-common artifact even inside Eclipse. @@ -28,6 +38,16 @@ scijava:help Call mvn scijava:help -Ddetail=true -Dgoal= to display parameter details. +scijava:install-artifact + Downloads .jar artifacts and their dependencies into a SciJava application + directory structure. ImageJ 1.x plugins (identified by containing a + plugins.config file) get copied to the plugins/ subdirectory and all other + .jar files to jars/. However, you can override this decision by setting the + scijava.app.subdirectory property to a specific subdirectory. It expects the + location of the SciJava application directory to be specified in the + scijava.app.directory property (which can be set on the Maven command-line). + If said property is not set, the install-artifact goal is skipped. + scijava:set-rootdir Sets the project.rootdir property to the top-level directory of the current Maven project structure. @@ -47,8 +67,9 @@ scijava:verify-no-snapshots Usage ----- -It is recommended to enable the set-rootdir goal by making the -[SciJava POM](http://github.com/scijava/pom-scijava) the parent project: +It is recommended to enable the _set-rootdir_ as well as the _copy-jars_ +goal by making the [SciJava POM](http://github.com/scijava/pom-scijava) +the parent project: ```xml @@ -78,6 +99,13 @@ Alternatively, you can include the plugin explicitly in the life cycle: set-rootdir + + copy-jars + install + + copy-jars + + From 744d8f20afa3561cd5d1727b7e142c74ebbf4edd Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Wed, 8 Aug 2018 07:13:30 +0200 Subject: [PATCH 09/16] Add compatibility integration test --- src/it/imagej-property-compatibility/pom.xml | 79 +++++++++++++++++++ .../imagej-property-compatibility/setup.bsh | 44 +++++++++++ .../src/main/resources/empty.txt | 0 .../imagej-property-compatibility/verify.bsh | 58 ++++++++++++++ 4 files changed, 181 insertions(+) create mode 100644 src/it/imagej-property-compatibility/pom.xml create mode 100644 src/it/imagej-property-compatibility/setup.bsh create mode 100644 src/it/imagej-property-compatibility/src/main/resources/empty.txt create mode 100644 src/it/imagej-property-compatibility/verify.bsh diff --git a/src/it/imagej-property-compatibility/pom.xml b/src/it/imagej-property-compatibility/pom.xml new file mode 100644 index 0000000..56a4ff5 --- /dev/null +++ b/src/it/imagej-property-compatibility/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + example-artifact + 1.0.0-SNAPSHOT + jar + An example artifact to test backwards compatibility with imagej-based properties + + + ${project.basedir}/target/ImageJ.app/ + plugins + older + + + + + + org.scijava + scijava-maven-plugin + ${scijava-maven.version} + + + copy-jars + install + + copy-jars + + + + install-artifact + install + + install-artifact + + + ${project.basedir}/target/Other.app/ + plugins + older + ${project.groupId}:${project.artifactId}:${project.version} + + + + + + + diff --git a/src/it/imagej-property-compatibility/setup.bsh b/src/it/imagej-property-compatibility/setup.bsh new file mode 100644 index 0000000..42113bd --- /dev/null +++ b/src/it/imagej-property-compatibility/setup.bsh @@ -0,0 +1,44 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +// copy-jars +if (!plugins.exists()) plugins.mkdirs(); +touchFile(new File(plugins, "example-artifact-1.1.0.jar")); + +// install-artifact +other = new File(basedir, "target/Other.app/"); +if (!other.exists()) other.mkdirs(); + +otherPlugins = new File(other, "plugins/"); +if (!otherPlugins.exists()) otherPlugins.mkdirs(); + +touchFile(new File(otherPlugins, "example-artifact-2.1.0.jar")); diff --git a/src/it/imagej-property-compatibility/src/main/resources/empty.txt b/src/it/imagej-property-compatibility/src/main/resources/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/it/imagej-property-compatibility/verify.bsh b/src/it/imagej-property-compatibility/verify.bsh new file mode 100644 index 0000000..3fa544f --- /dev/null +++ b/src/it/imagej-property-compatibility/verify.bsh @@ -0,0 +1,58 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2012 - 2016 Board of Regents of the University of + * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck + * Institute of Molecular Cell Biology and Genetics. + * %% + * 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. + * + * 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 COPYRIGHT HOLDERS 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. + * #L% + */ +source(new File(basedir, "../../../src/it/lib.bsh").getPath()); + +// copy-jars +newer = new File(plugins, "example-artifact-1.1.0.jar"); +assertTrue("Should exist: " + newer, newer.exists()); + +// install-artifact +other = new File(basedir, "target/Other.app/"); +assertTrue("Should exist: "+ other, other.exists()); + +otherPlugins = new File(other, "plugins/"); +assertTrue("Should exist: "+ otherPlugins, otherPlugins.exists()); + +newer = new File(otherPlugins, "example-artifact-2.1.0.jar"); +assertTrue("Should exist: " + newer, newer.exists()); +toInstall = new File(otherPlugins, "example-artifact-1.0.0-SNAPSHOT.jar"); +assertTrue("Should not exist: " + newer, !toInstall.exists()); + +buildLog = readFile(new File(basedir, "build.log")); +assertTrue("Found other version that is incompatible':\n" + buildLog, + buildLog.contains("Found other version that is incompatible")); + +assertTrue("Log should contain warning about legacy property 'imagej.app.directory'", + buildLog.contains("Property 'imagej.app.directory' is deprecated. Use 'scijava.app.directory' instead")); +assertTrue("Log should contain warning about legacy property 'imagej.app.subdirectory'", + buildLog.contains("Property 'imagej.app.subdirectory' is deprecated. Use 'scijava.app.subdirectory' instead")); +assertTrue("Log should contain warning about legacy property 'imagej.deleteOtherVersions'", + buildLog.contains("Property 'imagej.deleteOtherVersions' is deprecated. Use 'scijava.deleteOtherVersions' instead")); From 6b5cd6bd4198e092cbdcd86a3182870981595aae Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Wed, 8 Aug 2018 08:08:13 +0200 Subject: [PATCH 10/16] Add compatibility for legacy configuration params --- .../maven/plugin/install/CopyJarsMojo.java | 32 ++++- .../plugin/install/InstallArtifactMojo.java | 126 ++++++++++++++++-- 2 files changed, 137 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java index bbefd51..470c677 100644 --- a/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java @@ -133,7 +133,7 @@ public class CopyJarsMojo extends AbstractCopyJarsMojo { *

*/ @Deprecated - @Parameter(property = imagejDeleteOtherVersionsPolicyProperty, defaultValue = "older") + @Parameter(property = imagejDeleteOtherVersionsPolicyProperty) private OtherVersions imagejDeleteOtherVersionsPolicy; /** @@ -198,8 +198,14 @@ public void execute() throws MojoExecutionException { // Keep backwards compatibility to imagej.app.directory try { Object evaluate = evaluator.evaluate("${"+imagejDirectoryProperty+"}"); - if (evaluate != null) { - getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); + + // Use imagejDirectory if it is set (directly or via imagej.app.directory) + if (imagejDirectory != null) { + if (evaluate == null) { + getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); + } else { + getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); + } // TODO How do we want to handle cases where both are provided. Which // property should take precedence? @@ -213,8 +219,14 @@ public void execute() throws MojoExecutionException { // Keep backwards compatibility to imagej.app.subdirectory try { Object evaluate = evaluator.evaluate("${"+imagejSubdirectoryProperty+"}"); - if (evaluate != null) { - getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); + + // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) + if (imagejSubdirectory != null) { + if (evaluate == null) { + getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); + } else { + getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); + } // TODO How do we want to handle cases where both are provided. Which // property should take precedence? @@ -228,8 +240,14 @@ public void execute() throws MojoExecutionException { // Keep backwards compatibility to imagej.deleteOtherVersions try { Object evaluate = evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}"); - if (evaluate != null) { - getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + + // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) + if (imagejDeleteOtherVersionsPolicy != null) { + if (evaluate == null) { + getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); + } else { + getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + } // TODO How do we want to handle cases where both are provided. Which // property should take precedence? diff --git a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java index 6d29f03..81f78a6 100644 --- a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java @@ -70,6 +70,7 @@ import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.StringUtils; +import org.scijava.maven.plugin.install.AbstractCopyJarsMojo.OtherVersions; /** * Downloads .jar artifacts and their dependencies into a SciJava application @@ -90,25 +91,46 @@ public class InstallArtifactMojo extends AbstractCopyJarsMojo { /** - * Path to the ImageJ.app/ directory to which artifacts are installed. + * Path to the ImageJ.app/ directory to which artifacts are copied. *

* If it is not a directory, no .jar files are copied. *

*/ - @Parameter(property = imagejDirectoryProperty) + @Deprecated + @Parameter(property = imagejDirectoryProperty, required = false) private String imagejDirectory; + /** + * Path to a SciJava application directory (e.g. ImageJ.app) to which + * artifacts are copied. + *

+ * If it is not a directory, no .jar files are copied. + *

+ */ + @Parameter(property = appDirectoryProperty, required = false) + private String appDirectory; + /** * The name of the property pointing to the subdirectory (beneath e.g. - * {@code jars/} or {@code plugins/}) to which the artifact should be - * copied. + * {@code jars/} or {@code plugins/}) to which the artifact should be copied. *

* If no property of that name exists, no subdirectory will be used. *

*/ - @Parameter( property = imagejSubdirectoryProperty, required = false ) + @Deprecated + @Parameter(property = imagejSubdirectoryProperty, required = false) private String imagejSubdirectory; + /** + * The name of the property pointing to the subdirectory (beneath e.g. + * {@code jars/} or {@code plugins/}) to which the artifact should be copied. + *

+ * If no property of that name exists, no subdirectory will be used. + *

+ */ + @Parameter(property = appSubdirectoryProperty, required = false) + private String appSubdirectory; + /** * Whether to delete other versions when copying the files. *

@@ -129,7 +151,19 @@ public class InstallArtifactMojo extends AbstractCopyJarsMojo { * other versions. *

*/ - @Parameter(property = imagejDeleteOtherVersionsPolicyProperty, defaultValue = "older") + @Deprecated + @Parameter(property = imagejDeleteOtherVersionsPolicyProperty) + private OtherVersions imagejDeleteOtherVersionsPolicy; + + /** + * Whether to delete other versions when copying the files. + *

+ * When copying a file and its dependencies to a SciJava application directory + * and there are other versions of the same file, we can warn or delete those + * other versions. + *

+ */ + @Parameter(property = deleteOtherVersionsPolicyProperty, defaultValue = "older") private OtherVersions deleteOtherVersionsPolicy; /** @@ -239,12 +273,13 @@ public class InstallArtifactMojo extends AbstractCopyJarsMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { - // Keep backwards compatibility to delete.other.versions ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); + + // Keep backwards compatibility to delete.other.versions try { Object evaluate = evaluator.evaluate("${"+deleteOtherVersionsProperty+"}"); if (evaluate != null) { - getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ imagejDeleteOtherVersionsPolicyProperty +"' instead"); + getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; } } @@ -252,19 +287,82 @@ public void execute() throws MojoExecutionException, MojoFailureException { getLog().warn(e); } - if (imagejDirectory == null) { + // Keep backwards compatibility to imagej.app.directory + try { + Object evaluate = evaluator.evaluate("${"+imagejDirectoryProperty+"}"); + + // Use imagejDirectory if it is set (directly or via imagej.app.directory) + if (imagejDirectory != null) { + if (evaluate == null) { + getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); + } else { + getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); + } + + // TODO How do we want to handle cases where both are provided. Which + // property should take precedence? + appDirectory = imagejDirectory; + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + + // Keep backwards compatibility to imagej.app.subdirectory + try { + Object evaluate = evaluator.evaluate("${"+imagejSubdirectoryProperty+"}"); + + // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) + if (imagejSubdirectory != null) { + if (evaluate == null) { + getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); + } else { + getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); + } + + // TODO How do we want to handle cases where both are provided. Which + // property should take precedence? + appSubdirectory = imagejSubdirectory; + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + + // Keep backwards compatibility to imagej.deleteOtherVersions + try { + Object evaluate = evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}"); + + // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) + if (imagejDeleteOtherVersionsPolicy != null) { + if (evaluate == null) { + getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); + } else { + getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + } + + // TODO How do we want to handle cases where both are provided. Which + // property should take precedence? + deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + + if (appDirectory == null) { throw new MojoExecutionException( - "The '"+imagejDirectoryProperty+"' property is unset!"); + "The '"+appDirectoryProperty+"' property is unset!"); } - File imagejDir = new File(imagejDirectory); + File imagejDir = new File(appDirectory); if (!imagejDir.isDirectory() && !imagejDir.mkdirs()) { throw new MojoFailureException("Could not make directory: " + imagejDir); } - if ( imagejSubdirectory == null ) + if ( appSubdirectory == null ) { - getLog().info( "No property name for the " + imagejSubdirectoryProperty + + getLog().info( "No property name for the " + appDirectoryProperty + " directory location was specified; Installing in default location" ); } @@ -326,7 +424,7 @@ public boolean accept(Node node, List parents) { try { if ( isSameGAV(coordinate, result.getArtifact()) ) { - installArtifact( result.getArtifact(), imagejDir, imagejSubdirectory, false, deleteOtherVersionsPolicy ); + installArtifact( result.getArtifact(), imagejDir, appSubdirectory, false, deleteOtherVersionsPolicy ); continue; } if (!ignoreDependencies) From 39024f14d1a934a6795a3a58b039fdece81e1d83 Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Mon, 13 Aug 2018 07:28:21 +0200 Subject: [PATCH 11/16] Improve compatibility handling If one scijava.* property is set, ignore imagej.* properties entirely. --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../maven/plugin/install/CopyJarsMojo.java | 136 ++++++++---------- .../plugin/install/InstallArtifactMojo.java | 136 ++++++++---------- 4 files changed, 122 insertions(+), 154 deletions(-) diff --git a/src/it/delete-other-versions-property-false/pom.xml b/src/it/delete-other-versions-property-false/pom.xml index 7d14c60..d88cf85 100644 --- a/src/it/delete-other-versions-property-false/pom.xml +++ b/src/it/delete-other-versions-property-false/pom.xml @@ -39,7 +39,7 @@ An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 false diff --git a/src/it/delete-other-versions-property-true/pom.xml b/src/it/delete-other-versions-property-true/pom.xml index 620a66f..1613cd6 100644 --- a/src/it/delete-other-versions-property-true/pom.xml +++ b/src/it/delete-other-versions-property-true/pom.xml @@ -39,7 +39,7 @@ An example ImageJ 1.x plugin to test scijava-maven-plugin's CopyJarsMojo - ${project.basedir}/target/ImageJ.app/ + ${project.basedir}/target/ImageJ.app/ UTF-8 true diff --git a/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java index 470c677..4b3e0d3 100644 --- a/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java @@ -181,82 +181,8 @@ public class CopyJarsMojo extends AbstractCopyJarsMojo { @Override public void execute() throws MojoExecutionException { - ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); - - // Keep backwards compatibility to delete.other.versions - try { - Object evaluate = evaluator.evaluate("${"+deleteOtherVersionsProperty+"}"); - if (evaluate != null) { - getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); - deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } - - // Keep backwards compatibility to imagej.app.directory - try { - Object evaluate = evaluator.evaluate("${"+imagejDirectoryProperty+"}"); - - // Use imagejDirectory if it is set (directly or via imagej.app.directory) - if (imagejDirectory != null) { - if (evaluate == null) { - getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); - } else { - getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); - } - - // TODO How do we want to handle cases where both are provided. Which - // property should take precedence? - appDirectory = imagejDirectory; - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } - - // Keep backwards compatibility to imagej.app.subdirectory - try { - Object evaluate = evaluator.evaluate("${"+imagejSubdirectoryProperty+"}"); - - // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) - if (imagejSubdirectory != null) { - if (evaluate == null) { - getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); - } else { - getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); - } - - // TODO How do we want to handle cases where both are provided. Which - // property should take precedence? - appSubdirectory = imagejSubdirectory; - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } - - // Keep backwards compatibility to imagej.deleteOtherVersions - try { - Object evaluate = evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}"); - - // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) - if (imagejDeleteOtherVersionsPolicy != null) { - if (evaluate == null) { - getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); - } else { - getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); - } - - // TODO How do we want to handle cases where both are provided. Which - // property should take precedence? - deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } + // Keep backwards compatibility + handleBackwardsCompatibility(); if (appDirectory == null) { if (hasIJ1Dependency(project)) getLog().info( @@ -315,4 +241,62 @@ public void execute() throws MojoExecutionException { "Couldn't resolve dependencies for artifact: " + e.getMessage(), e); } } + + /** + * TODO Javadoc + */ + private void handleBackwardsCompatibility() { + ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); + + try { + // If at least one scijava.* property is set, ignore imagej.* properties + if (evaluator.evaluate("${" + appDirectoryProperty + "}") == null && + evaluator.evaluate("${" + appSubdirectoryProperty + "}") == null && + evaluator.evaluate("${" + deleteOtherVersionsPolicyProperty + "}") == null) + { + + // Keep backwards compatibility to delete.other.versions + if (evaluator.evaluate("${"+deleteOtherVersionsProperty+"}") != null) { + getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; + } + + // Keep backwards compatibility to imagej.app.directory + // Use imagejDirectory if it is set (directly or via imagej.app.directory) + if (imagejDirectory != null) { + if (evaluator.evaluate("${"+imagejDirectoryProperty+"}") == null) { + getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); + } else { + getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); + } + appDirectory = imagejDirectory; + } + + // Keep backwards compatibility to imagej.app.subdirectory + // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) + if (imagejSubdirectory != null) { + if (evaluator.evaluate("${"+imagejSubdirectoryProperty+"}") == null) { + getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); + } else { + getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); + } + appSubdirectory = imagejSubdirectory; + } + + // Keep backwards compatibility to imagej.deleteOtherVersions + // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) + if (imagejDeleteOtherVersionsPolicy != null) { + if (evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}") == null) { + getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); + } else { + getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + } + deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; + } + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + } } diff --git a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java index 81f78a6..15d5b17 100644 --- a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java @@ -273,82 +273,8 @@ public class InstallArtifactMojo extends AbstractCopyJarsMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { - ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); - - // Keep backwards compatibility to delete.other.versions - try { - Object evaluate = evaluator.evaluate("${"+deleteOtherVersionsProperty+"}"); - if (evaluate != null) { - getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); - deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } - - // Keep backwards compatibility to imagej.app.directory - try { - Object evaluate = evaluator.evaluate("${"+imagejDirectoryProperty+"}"); - - // Use imagejDirectory if it is set (directly or via imagej.app.directory) - if (imagejDirectory != null) { - if (evaluate == null) { - getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); - } else { - getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); - } - - // TODO How do we want to handle cases where both are provided. Which - // property should take precedence? - appDirectory = imagejDirectory; - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } - - // Keep backwards compatibility to imagej.app.subdirectory - try { - Object evaluate = evaluator.evaluate("${"+imagejSubdirectoryProperty+"}"); - - // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) - if (imagejSubdirectory != null) { - if (evaluate == null) { - getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); - } else { - getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); - } - - // TODO How do we want to handle cases where both are provided. Which - // property should take precedence? - appSubdirectory = imagejSubdirectory; - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } - - // Keep backwards compatibility to imagej.deleteOtherVersions - try { - Object evaluate = evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}"); - - // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) - if (imagejDeleteOtherVersionsPolicy != null) { - if (evaluate == null) { - getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); - } else { - getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); - } - - // TODO How do we want to handle cases where both are provided. Which - // property should take precedence? - deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } + // Keep backwards compatibility + handleBackwardsCompatibility(); if (appDirectory == null) { throw new MojoExecutionException( @@ -443,6 +369,64 @@ public boolean accept(Node node, List parents) { } } + /** + * TODO Javadoc + */ + private void handleBackwardsCompatibility() { + ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); + + try { + // If at least one scijava.* property is set, ignore imagej.* properties + if (evaluator.evaluate("${" + appDirectoryProperty + "}") == null && + evaluator.evaluate("${" + appSubdirectoryProperty + "}") == null && + evaluator.evaluate("${" + deleteOtherVersionsPolicyProperty + "}") == null) + { + + // Keep backwards compatibility to delete.other.versions + if (evaluator.evaluate("${"+deleteOtherVersionsProperty+"}") != null) { + getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; + } + + // Keep backwards compatibility to imagej.app.directory + // Use imagejDirectory if it is set (directly or via imagej.app.directory) + if (imagejDirectory != null) { + if (evaluator.evaluate("${"+imagejDirectoryProperty+"}") == null) { + getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); + } else { + getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); + } + appDirectory = imagejDirectory; + } + + // Keep backwards compatibility to imagej.app.subdirectory + // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) + if (imagejSubdirectory != null) { + if (evaluator.evaluate("${"+imagejSubdirectoryProperty+"}") == null) { + getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); + } else { + getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); + } + appSubdirectory = imagejSubdirectory; + } + + // Keep backwards compatibility to imagej.deleteOtherVersions + // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) + if (imagejDeleteOtherVersionsPolicy != null) { + if (evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}") == null) { + getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); + } else { + getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + } + deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; + } + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + } + /** * Checks if a {@link DependableCoordinate} and an {@link Artifact} share * the same GAV. From 8fa6599aaafac999497a3946f542e27a82deb14c Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Mon, 13 Aug 2018 07:37:02 +0200 Subject: [PATCH 12/16] Move compatibility mode to AbstractCopyJarsMojo --- .../plugin/install/AbstractCopyJarsMojo.java | 153 +++++++++++++++++ .../maven/plugin/install/CopyJarsMojo.java | 159 +---------------- .../plugin/install/InstallArtifactMojo.java | 160 +----------------- 3 files changed, 157 insertions(+), 315 deletions(-) diff --git a/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java b/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java index 396ccb1..b3cd9fb 100644 --- a/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java @@ -50,8 +50,13 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.PluginParameterExpressionEvaluator; +import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.interpolation.ObjectBasedValueSource; import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; @@ -70,6 +75,95 @@ */ public abstract class AbstractCopyJarsMojo extends AbstractMojo { + /** + * Path to the ImageJ.app/ directory to which artifacts are copied. + *

+ * If it is not a directory, no .jar files are copied. + *

+ */ + @Deprecated + @Parameter(property = imagejDirectoryProperty, required = false) + String imagejDirectory; + + /** + * Path to a SciJava application directory (e.g. ImageJ.app) to which + * artifacts are copied. + *

+ * If it is not a directory, no .jar files are copied. + *

+ */ + @Parameter(property = appDirectoryProperty, required = false) + String appDirectory; + + /** + * The name of the property pointing to the subdirectory (beneath e.g. + * {@code jars/} or {@code plugins/}) to which the artifact should be copied. + *

+ * If no property of that name exists, no subdirectory will be used. + *

+ */ + @Deprecated + @Parameter(property = imagejSubdirectoryProperty, required = false) + String imagejSubdirectory; + + /** + * The name of the property pointing to the subdirectory (beneath e.g. + * {@code jars/} or {@code plugins/}) to which the artifact should be copied. + *

+ * If no property of that name exists, no subdirectory will be used. + *

+ */ + @Parameter(property = appSubdirectoryProperty, required = false) + String appSubdirectory; + + /** + * Whether to delete other versions when copying the files. + *

+ * When copying a file and its dependencies to an ImageJ.app/ directory and + * there are other versions of the same file, we can warn or delete those + * other versions. + *

+ */ + @Deprecated + @Parameter(property = deleteOtherVersionsProperty) + boolean deleteOtherVersions; + + /** + * Whether to delete other versions when copying the files. + *

+ * When copying a file and its dependencies to an ImageJ.app/ directory and + * there are other versions of the same file, we can warn or delete those + * other versions. + *

+ */ + @Deprecated + @Parameter(property = imagejDeleteOtherVersionsPolicyProperty) + OtherVersions imagejDeleteOtherVersionsPolicy; + + /** + * Whether to delete other versions when copying the files. + *

+ * When copying a file and its dependencies to a SciJava application directory + * and there are other versions of the same file, we can warn or delete those + * other versions. + *

+ */ + @Parameter(property = deleteOtherVersionsPolicyProperty, defaultValue = "older") + OtherVersions deleteOtherVersionsPolicy; + + /** + * If this option is set to true, only the artifact will be + * copied - without its dependencies. + */ + @Parameter(property = ignoreDependenciesProperty, defaultValue = "false") + boolean ignoreDependencies; + + @Parameter(defaultValue = "${session}") + MavenSession session; + + @Parameter( defaultValue = "${mojoExecution}", readonly = true ) + MojoExecution mojoExecution; + public static final String imagejDirectoryProperty = "imagej.app.directory"; public static final String imagejSubdirectoryProperty = "imagej.app.subdirectory"; public static final String deleteOtherVersionsProperty = "delete.other.versions"; @@ -84,6 +178,65 @@ public enum OtherVersions { always, older, never } + /** + * Handles the backward compatibility with properties previously defined by + * imagej-maven-plugin. + */ + void handleBackwardCompatibility() { + ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); + + try { + // If at least one scijava.* property is set, ignore imagej.* properties + if (evaluator.evaluate("${" + appDirectoryProperty + "}") == null && + evaluator.evaluate("${" + appSubdirectoryProperty + "}") == null && + evaluator.evaluate("${" + deleteOtherVersionsPolicyProperty + "}") == null) + { + + // Keep backwards compatibility to delete.other.versions + if (evaluator.evaluate("${"+deleteOtherVersionsProperty+"}") != null) { + getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; + } + + // Keep backwards compatibility to imagej.app.directory + // Use imagejDirectory if it is set (directly or via imagej.app.directory) + if (imagejDirectory != null) { + if (evaluator.evaluate("${"+imagejDirectoryProperty+"}") == null) { + getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); + } else { + getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); + } + appDirectory = imagejDirectory; + } + + // Keep backwards compatibility to imagej.app.subdirectory + // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) + if (imagejSubdirectory != null) { + if (evaluator.evaluate("${"+imagejSubdirectoryProperty+"}") == null) { + getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); + } else { + getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); + } + appSubdirectory = imagejSubdirectory; + } + + // Keep backwards compatibility to imagej.deleteOtherVersions + // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) + if (imagejDeleteOtherVersionsPolicy != null) { + if (evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}") == null) { + getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); + } else { + getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + } + deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; + } + } + } + catch (ExpressionEvaluationException e) { + getLog().warn(e); + } + } + protected boolean hasIJ1Dependency(final MavenProject project) { final List dependencies = project.getDependencies(); for (final Dependency dependency : dependencies) { diff --git a/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java index 4b3e0d3..8e73575 100644 --- a/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/CopyJarsMojo.java @@ -34,10 +34,7 @@ import java.io.File; import java.io.IOException; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.PluginParameterExpressionEvaluator; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -50,8 +47,6 @@ import org.apache.maven.shared.dependencies.DefaultDependableCoordinate; import org.apache.maven.shared.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.dependencies.resolve.DependencyResolverException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; /** * Copies .jar artifacts and their dependencies into a SciJava application @@ -71,101 +66,12 @@ @Mojo(name = "copy-jars", requiresProject = true, requiresOnline = true) public class CopyJarsMojo extends AbstractCopyJarsMojo { - /** - * Path to the ImageJ.app/ directory to which artifacts are copied. - *

- * If it is not a directory, no .jar files are copied. - *

- */ - @Deprecated - @Parameter(property = imagejDirectoryProperty, required = false) - private String imagejDirectory; - - /** - * Path to a SciJava application directory (e.g. ImageJ.app) to which - * artifacts are copied. - *

- * If it is not a directory, no .jar files are copied. - *

- */ - @Parameter(property = appDirectoryProperty, required = false) - private String appDirectory; - - /** - * The name of the property pointing to the subdirectory (beneath e.g. - * {@code jars/} or {@code plugins/}) to which the artifact should be copied. - *

- * If no property of that name exists, no subdirectory will be used. - *

- */ - @Deprecated - @Parameter(property = imagejSubdirectoryProperty, required = false) - private String imagejSubdirectory; - - /** - * The name of the property pointing to the subdirectory (beneath e.g. - * {@code jars/} or {@code plugins/}) to which the artifact should be copied. - *

- * If no property of that name exists, no subdirectory will be used. - *

- */ - @Parameter(property = appSubdirectoryProperty, required = false) - private String appSubdirectory; - - /** - * Whether to delete other versions when copying the files. - *

- * When copying a file and its dependencies to an ImageJ.app/ directory and - * there are other versions of the same file, we can warn or delete those - * other versions. - *

- */ - @Deprecated - @Parameter(property = deleteOtherVersionsProperty) - private boolean deleteOtherVersions; - - /** - * Whether to delete other versions when copying the files. - *

- * When copying a file and its dependencies to an ImageJ.app/ directory and - * there are other versions of the same file, we can warn or delete those - * other versions. - *

- */ - @Deprecated - @Parameter(property = imagejDeleteOtherVersionsPolicyProperty) - private OtherVersions imagejDeleteOtherVersionsPolicy; - - /** - * Whether to delete other versions when copying the files. - *

- * When copying a file and its dependencies to a SciJava application directory - * and there are other versions of the same file, we can warn or delete those - * other versions. - *

- */ - @Parameter(property = deleteOtherVersionsPolicyProperty, defaultValue = "older") - private OtherVersions deleteOtherVersionsPolicy; - - /** - * If this option is set to true, only the artifact will be - * copied - without its dependencies. - */ - @Parameter(property = ignoreDependenciesProperty, defaultValue = "false") - private boolean ignoreDependencies; - /** * Project */ @Parameter(defaultValue = "${project}", required=true, readonly = true) private MavenProject project; - /** - * Session - */ - @Parameter(defaultValue = "${session}") - private MavenSession session; - /** * The dependency resolver to. */ @@ -176,13 +82,10 @@ public class CopyJarsMojo extends AbstractCopyJarsMojo { private File appDir; - @Parameter( defaultValue = "${mojoExecution}", readonly = true ) - MojoExecution mojoExecution; - @Override public void execute() throws MojoExecutionException { - // Keep backwards compatibility - handleBackwardsCompatibility(); + // Keep backward compatibility + handleBackwardCompatibility(); if (appDirectory == null) { if (hasIJ1Dependency(project)) getLog().info( @@ -241,62 +144,4 @@ public void execute() throws MojoExecutionException { "Couldn't resolve dependencies for artifact: " + e.getMessage(), e); } } - - /** - * TODO Javadoc - */ - private void handleBackwardsCompatibility() { - ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); - - try { - // If at least one scijava.* property is set, ignore imagej.* properties - if (evaluator.evaluate("${" + appDirectoryProperty + "}") == null && - evaluator.evaluate("${" + appSubdirectoryProperty + "}") == null && - evaluator.evaluate("${" + deleteOtherVersionsPolicyProperty + "}") == null) - { - - // Keep backwards compatibility to delete.other.versions - if (evaluator.evaluate("${"+deleteOtherVersionsProperty+"}") != null) { - getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); - deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; - } - - // Keep backwards compatibility to imagej.app.directory - // Use imagejDirectory if it is set (directly or via imagej.app.directory) - if (imagejDirectory != null) { - if (evaluator.evaluate("${"+imagejDirectoryProperty+"}") == null) { - getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); - } else { - getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); - } - appDirectory = imagejDirectory; - } - - // Keep backwards compatibility to imagej.app.subdirectory - // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) - if (imagejSubdirectory != null) { - if (evaluator.evaluate("${"+imagejSubdirectoryProperty+"}") == null) { - getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); - } else { - getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); - } - appSubdirectory = imagejSubdirectory; - } - - // Keep backwards compatibility to imagej.deleteOtherVersions - // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) - if (imagejDeleteOtherVersionsPolicy != null) { - if (evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}") == null) { - getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); - } else { - getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); - } - deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; - } - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } - } } diff --git a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java index 15d5b17..9b1693e 100644 --- a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java @@ -46,11 +46,8 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.PluginParameterExpressionEvaluator; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -67,10 +64,7 @@ import org.apache.maven.shared.dependencies.DependableCoordinate; import org.apache.maven.shared.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.dependencies.resolve.DependencyResolverException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.StringUtils; -import org.scijava.maven.plugin.install.AbstractCopyJarsMojo.OtherVersions; /** * Downloads .jar artifacts and their dependencies into a SciJava application @@ -90,95 +84,6 @@ @Mojo(name = "install-artifact", requiresProject=false) public class InstallArtifactMojo extends AbstractCopyJarsMojo { - /** - * Path to the ImageJ.app/ directory to which artifacts are copied. - *

- * If it is not a directory, no .jar files are copied. - *

- */ - @Deprecated - @Parameter(property = imagejDirectoryProperty, required = false) - private String imagejDirectory; - - /** - * Path to a SciJava application directory (e.g. ImageJ.app) to which - * artifacts are copied. - *

- * If it is not a directory, no .jar files are copied. - *

- */ - @Parameter(property = appDirectoryProperty, required = false) - private String appDirectory; - - /** - * The name of the property pointing to the subdirectory (beneath e.g. - * {@code jars/} or {@code plugins/}) to which the artifact should be copied. - *

- * If no property of that name exists, no subdirectory will be used. - *

- */ - @Deprecated - @Parameter(property = imagejSubdirectoryProperty, required = false) - private String imagejSubdirectory; - - /** - * The name of the property pointing to the subdirectory (beneath e.g. - * {@code jars/} or {@code plugins/}) to which the artifact should be copied. - *

- * If no property of that name exists, no subdirectory will be used. - *

- */ - @Parameter(property = appSubdirectoryProperty, required = false) - private String appSubdirectory; - - /** - * Whether to delete other versions when copying the files. - *

- * When copying a file and its dependencies to an ImageJ.app/ directory and - * there are other versions of the same file, we can warn or delete those - * other versions. - *

- */ - @Deprecated - @Parameter(property = deleteOtherVersionsProperty) - private boolean deleteOtherVersions; - - /** - * Whether to delete other versions when copying the files. - *

- * When copying a file and its dependencies to an ImageJ.app/ directory and - * there are other versions of the same file, we can warn or delete those - * other versions. - *

- */ - @Deprecated - @Parameter(property = imagejDeleteOtherVersionsPolicyProperty) - private OtherVersions imagejDeleteOtherVersionsPolicy; - - /** - * Whether to delete other versions when copying the files. - *

- * When copying a file and its dependencies to a SciJava application directory - * and there are other versions of the same file, we can warn or delete those - * other versions. - *

- */ - @Parameter(property = deleteOtherVersionsPolicyProperty, defaultValue = "older") - private OtherVersions deleteOtherVersionsPolicy; - - /** - * If this option is set to true, only the artifact will be - * copied - without its dependencies. - */ - @Parameter(property = ignoreDependenciesProperty, defaultValue = "false") - private boolean ignoreDependencies; - - /** - * Session - */ - @Parameter(defaultValue = "${session}") - private MavenSession session; - /** * Used to look up Artifacts in the remote repository. */ @@ -268,13 +173,10 @@ public class InstallArtifactMojo extends AbstractCopyJarsMojo { */ private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); - @Parameter( defaultValue = "${mojoExecution}", readonly = true ) - MojoExecution mojoExecution; - @Override public void execute() throws MojoExecutionException, MojoFailureException { - // Keep backwards compatibility - handleBackwardsCompatibility(); + // Keep backward compatibility + handleBackwardCompatibility(); if (appDirectory == null) { throw new MojoExecutionException( @@ -369,64 +271,6 @@ public boolean accept(Node node, List parents) { } } - /** - * TODO Javadoc - */ - private void handleBackwardsCompatibility() { - ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); - - try { - // If at least one scijava.* property is set, ignore imagej.* properties - if (evaluator.evaluate("${" + appDirectoryProperty + "}") == null && - evaluator.evaluate("${" + appSubdirectoryProperty + "}") == null && - evaluator.evaluate("${" + deleteOtherVersionsPolicyProperty + "}") == null) - { - - // Keep backwards compatibility to delete.other.versions - if (evaluator.evaluate("${"+deleteOtherVersionsProperty+"}") != null) { - getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); - deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; - } - - // Keep backwards compatibility to imagej.app.directory - // Use imagejDirectory if it is set (directly or via imagej.app.directory) - if (imagejDirectory != null) { - if (evaluator.evaluate("${"+imagejDirectoryProperty+"}") == null) { - getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); - } else { - getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); - } - appDirectory = imagejDirectory; - } - - // Keep backwards compatibility to imagej.app.subdirectory - // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) - if (imagejSubdirectory != null) { - if (evaluator.evaluate("${"+imagejSubdirectoryProperty+"}") == null) { - getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); - } else { - getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); - } - appSubdirectory = imagejSubdirectory; - } - - // Keep backwards compatibility to imagej.deleteOtherVersions - // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) - if (imagejDeleteOtherVersionsPolicy != null) { - if (evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}") == null) { - getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); - } else { - getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); - } - deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; - } - } - } - catch (ExpressionEvaluationException e) { - getLog().warn(e); - } - } - /** * Checks if a {@link DependableCoordinate} and an {@link Artifact} share * the same GAV. From 77719066e44c2e8822cd5f8c643f10138a31a84d Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Mon, 13 Aug 2018 07:41:31 +0200 Subject: [PATCH 13/16] Add info message to clarify compatibility mode --- .../org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java b/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java index b3cd9fb..b42a3c2 100644 --- a/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java @@ -230,6 +230,8 @@ void handleBackwardCompatibility() { } deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; } + } else { + getLog().info("At least one scijava.* property is set. Ignoring imagej.* properties"); } } catch (ExpressionEvaluationException e) { From caac4cb5271385a5d53178a74d034c82271ab69a Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Fri, 31 Aug 2018 07:17:22 +0200 Subject: [PATCH 14/16] Clean up --- .../plugin/install/AbstractCopyJarsMojo.java | 98 ++++++++++++------- .../plugin/install/InstallArtifactMojo.java | 10 +- 2 files changed, 70 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java b/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java index b42a3c2..122c5ae 100644 --- a/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/AbstractCopyJarsMojo.java @@ -183,55 +183,87 @@ public enum OtherVersions { * imagej-maven-plugin. */ void handleBackwardCompatibility() { - ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); + ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator( + session, mojoExecution); try { // If at least one scijava.* property is set, ignore imagej.* properties if (evaluator.evaluate("${" + appDirectoryProperty + "}") == null && evaluator.evaluate("${" + appSubdirectoryProperty + "}") == null && - evaluator.evaluate("${" + deleteOtherVersionsPolicyProperty + "}") == null) + evaluator.evaluate("${" + deleteOtherVersionsPolicyProperty + + "}") == null) { // Keep backwards compatibility to delete.other.versions - if (evaluator.evaluate("${"+deleteOtherVersionsProperty+"}") != null) { - getLog().warn("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); - deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older : OtherVersions.never; + if (evaluator.evaluate("${" + deleteOtherVersionsProperty + + "}") != null) + { + getLog().warn("Property '" + deleteOtherVersionsProperty + + "' is deprecated. Use '" + deleteOtherVersionsPolicyProperty + + "' instead"); + deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions.older + : OtherVersions.never; } // Keep backwards compatibility to imagej.app.directory - // Use imagejDirectory if it is set (directly or via imagej.app.directory) + // Use imagejDirectory if it is set (directly or via + // imagej.app.directory) if (imagejDirectory != null) { - if (evaluator.evaluate("${"+imagejDirectoryProperty+"}") == null) { - getLog().warn("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead"); - } else { - getLog().warn("Property '" + imagejDirectoryProperty + "' is deprecated. Use '"+ appDirectoryProperty +"' instead"); + if (evaluator.evaluate("${" + imagejDirectoryProperty + + "}") == null) + { + getLog().warn( + "Configuration property 'imagejDirectory' is deprecated." + + "Use 'appDirectory' instead"); + } + else { + getLog().warn("Property '" + imagejDirectoryProperty + + "' is deprecated. Use '" + appDirectoryProperty + "' instead"); } appDirectory = imagejDirectory; } // Keep backwards compatibility to imagej.app.subdirectory - // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory) + // Use imagejSubdirectory if it is set (directly or via + // imagej.app.subdirectory) if (imagejSubdirectory != null) { - if (evaluator.evaluate("${"+imagejSubdirectoryProperty+"}") == null) { - getLog().warn("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead"); - } else { - getLog().warn("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '"+ appSubdirectoryProperty +"' instead"); + if (evaluator.evaluate("${" + imagejSubdirectoryProperty + + "}") == null) + { + getLog().warn( + "Configuration property 'imagejSubdirectory' is deprecated." + + "Use 'appSubdirectory' instead"); + } + else { + getLog().warn("Property '" + imagejSubdirectoryProperty + + "' is deprecated. Use '" + appSubdirectoryProperty + "' instead"); } appSubdirectory = imagejSubdirectory; } // Keep backwards compatibility to imagej.deleteOtherVersions - // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions) + // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via + // imagej.deleteOtherVersions) if (imagejDeleteOtherVersionsPolicy != null) { - if (evaluator.evaluate("${"+imagejDeleteOtherVersionsPolicyProperty+"}") == null) { - getLog().warn("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead"); - } else { - getLog().warn("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '"+ deleteOtherVersionsPolicyProperty +"' instead"); + if (evaluator.evaluate("${" + + imagejDeleteOtherVersionsPolicyProperty + "}") == null) + { + getLog().warn( + "Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated." + + "Use 'deleteOtherVersionsPolicy' instead"); + } + else { + getLog().warn("Property '" + + imagejDeleteOtherVersionsPolicyProperty + + "' is deprecated. Use '" + deleteOtherVersionsPolicyProperty + + "' instead"); } deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy; } - } else { - getLog().info("At least one scijava.* property is set. Ignoring imagej.* properties"); + } + else { + getLog().info( + "At least one scijava.* property is set. Ignoring imagej.* properties"); } } catch (ExpressionEvaluationException e) { @@ -292,14 +324,14 @@ protected String interpolate(final String original, } protected void installArtifact(final Artifact artifact, - final File imagejDirectory, final boolean force, + final File appDirectory, final boolean force, final OtherVersions otherVersionsPolicy) throws IOException { - installArtifact(artifact, imagejDirectory, "", force, otherVersionsPolicy); + installArtifact(artifact, appDirectory, "", force, otherVersionsPolicy); } protected void installArtifact(final Artifact artifact, - final File imagejDirectory, final String subdirectory, final boolean force, + final File appDirectory, final String appSubdirectory, final boolean force, final OtherVersions otherVersionsPolicy) throws IOException { if (!"jar".equals(artifact.getType())) return; @@ -307,26 +339,26 @@ protected void installArtifact(final Artifact artifact, final File source = artifact.getFile(); final File targetDirectory; - if (subdirectory != null && !subdirectory.equals("")) { - targetDirectory = new File(imagejDirectory, subdirectory); + if (appSubdirectory != null && !appSubdirectory.equals("")) { + targetDirectory = new File(appDirectory, appSubdirectory); } else if (isIJ1Plugin(source)) { - targetDirectory = new File(imagejDirectory, "plugins"); + targetDirectory = new File(appDirectory, "plugins"); } else if ("ome".equals(artifact.getGroupId()) || ("loci".equals(artifact.getGroupId()) && (source.getName().startsWith( "scifio-4.4.") || source.getName().startsWith("jai_imageio-4.4.")))) { - targetDirectory = new File(imagejDirectory, "jars/bio-formats"); + targetDirectory = new File(appDirectory, "jars/bio-formats"); } else { - targetDirectory = new File(imagejDirectory, "jars"); + targetDirectory = new File(appDirectory, "jars"); } final String fileName = "Fiji_Updater".equals(artifact.getArtifactId()) ? artifact.getArtifactId() + ".jar" : source.getName(); final File target = new File(targetDirectory, fileName); boolean newerVersion = false; - final Path directoryPath = Paths.get(imagejDirectory.toURI()); + final Path directoryPath = Paths.get(appDirectory.toURI()); final Path targetPath = Paths.get(target.toURI()); final Collection otherVersions = // getEncroachingVersions(directoryPath, targetPath); @@ -422,8 +454,8 @@ private static boolean isIJ1Plugin(final File file) { */ private String majorVersion( String v ) { - final int dot = v.indexOf('.'); - return dot < 0 ? v : v.substring(0, dot); + final int dot = v.indexOf('.'); + return dot < 0 ? v : v.substring(0, dot); } /** diff --git a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java index 9b1693e..621375c 100644 --- a/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java +++ b/src/main/java/org/scijava/maven/plugin/install/InstallArtifactMojo.java @@ -182,10 +182,10 @@ public void execute() throws MojoExecutionException, MojoFailureException { throw new MojoExecutionException( "The '"+appDirectoryProperty+"' property is unset!"); } - File imagejDir = new File(appDirectory); - if (!imagejDir.isDirectory() && !imagejDir.mkdirs()) { + File appDir = new File(appDirectory); + if (!appDir.isDirectory() && !appDir.mkdirs()) { throw new MojoFailureException("Could not make directory: " + - imagejDir); + appDir); } if ( appSubdirectory == null ) @@ -252,11 +252,11 @@ public boolean accept(Node node, List parents) { try { if ( isSameGAV(coordinate, result.getArtifact()) ) { - installArtifact( result.getArtifact(), imagejDir, appSubdirectory, false, deleteOtherVersionsPolicy ); + installArtifact( result.getArtifact(), appDir, appSubdirectory, false, deleteOtherVersionsPolicy ); continue; } if (!ignoreDependencies) - installArtifact(result.getArtifact(), imagejDir, false, + installArtifact(result.getArtifact(), appDir, false, deleteOtherVersionsPolicy); } catch (IOException e) { From 0a4a63c33b347d10ea354d6dada06d1c4ebb2d85 Mon Sep 17 00:00:00 2001 From: Stefan Helfrich Date: Fri, 31 Aug 2018 07:28:43 +0200 Subject: [PATCH 15/16] Update LICENSE.txt and license headers --- LICENSE.txt | 5 +++-- pom.xml | 7 +++---- src/it/copy-jars/pom.xml | 8 ++++---- src/it/copy-jars/setup.bsh | 8 ++++---- src/it/copy-jars/src/main/java/Example_PlugIn.java | 8 ++++---- src/it/copy-jars/src/main/resources/plugins.config | 8 ++++---- src/it/copy-jars/verify.bsh | 8 ++++---- src/it/copy-to-subdirectory/pom.xml | 8 ++++---- src/it/copy-to-subdirectory/setup.bsh | 8 ++++---- .../src/main/resources/plugins.config | 8 ++++---- src/it/copy-to-subdirectory/verify.bsh | 8 ++++---- src/it/delete-other-versions-configuration/pom.xml | 8 ++++---- src/it/delete-other-versions-configuration/setup.bsh | 8 ++++---- .../src/main/resources/plugins.config | 8 ++++---- src/it/delete-other-versions-configuration/verify.bsh | 8 ++++---- src/it/delete-other-versions-in-subdirectory/pom.xml | 8 ++++---- src/it/delete-other-versions-in-subdirectory/setup.bsh | 8 ++++---- .../src/main/resources/plugins.config | 8 ++++---- src/it/delete-other-versions-in-subdirectory/verify.bsh | 8 ++++---- src/it/delete-other-versions-policy/pom.xml | 8 ++++---- src/it/delete-other-versions-policy/setup.bsh | 8 ++++---- .../src/main/resources/plugins.config | 8 ++++---- src/it/delete-other-versions-policy/verify.bsh | 8 ++++---- src/it/delete-other-versions-property-false/pom.xml | 8 ++++---- src/it/delete-other-versions-property-false/setup.bsh | 8 ++++---- .../src/main/resources/plugins.config | 8 ++++---- src/it/delete-other-versions-property-false/verify.bsh | 8 ++++---- src/it/delete-other-versions-property-true/pom.xml | 8 ++++---- src/it/delete-other-versions-property-true/setup.bsh | 8 ++++---- .../src/main/resources/plugins.config | 8 ++++---- src/it/delete-other-versions-property-true/verify.bsh | 8 ++++---- src/it/do-not-delete-natives/pom.xml | 8 ++++---- src/it/do-not-delete-natives/setup.bsh | 8 ++++---- .../src/main/resources/plugins.config | 8 ++++---- src/it/do-not-delete-natives/verify.bsh | 8 ++++---- src/it/exclusions/dependency/pom.xml | 8 ++++---- src/it/exclusions/excluded/pom.xml | 8 ++++---- src/it/exclusions/pom.xml | 8 ++++---- src/it/exclusions/setup.bsh | 8 ++++---- src/it/exclusions/to-copy/pom.xml | 8 ++++---- src/it/exclusions/verify.bsh | 8 ++++---- src/it/handle-missing-version-numbers/pom.xml | 8 ++++---- src/it/handle-missing-version-numbers/setup.bsh | 8 ++++---- src/it/handle-missing-version-numbers/verify.bsh | 8 ++++---- src/it/ignore-dependencies/pom.xml | 8 ++++---- src/it/ignore-dependencies/setup.bsh | 8 ++++---- .../ignore-dependencies/src/main/resources/plugins.config | 8 ++++---- src/it/ignore-dependencies/verify.bsh | 8 ++++---- src/it/imagej-property-compatibility/pom.xml | 8 ++++---- src/it/imagej-property-compatibility/setup.bsh | 8 ++++---- src/it/imagej-property-compatibility/verify.bsh | 8 ++++---- src/it/install-from-local-repo/only-local/pom.xml | 8 ++++---- src/it/install-from-local-repo/pom.xml | 8 ++++---- src/it/install-from-local-repo/setup.bsh | 8 ++++---- src/it/install-from-local-repo/to-copy/pom.xml | 8 ++++---- src/it/install-from-local-repo/verify.bsh | 8 ++++---- src/it/lib.bsh | 8 ++++---- src/it/missing-property/pom.xml | 8 ++++---- src/it/missing-property/verify.bsh | 8 ++++---- src/it/no-nag/pom.xml | 8 ++++---- src/it/no-nag/verify.bsh | 8 ++++---- src/it/settings.xml | 8 ++++---- src/it/skip-copy-jars/pom.xml | 8 ++++---- src/it/skip-copy-jars/verify.bsh | 8 ++++---- src/it/skip-optional/pom.xml | 8 ++++---- src/it/skip-optional/setup.bsh | 8 ++++---- src/it/skip-optional/verify.bsh | 8 ++++---- .../maven/plugin/AbstractSciJavaDependencyChecker.java | 5 +++-- src/main/java/org/scijava/maven/plugin/BumpMojo.java | 5 +++-- .../java/org/scijava/maven/plugin/DependencyUtils.java | 5 +++-- .../java/org/scijava/maven/plugin/EclipseHelperMojo.java | 5 +++-- .../scijava/maven/plugin/SciJavaDependencyChecker.java | 5 +++-- .../scijava/maven/plugin/SciJavaDependencyException.java | 5 +++-- .../org/scijava/maven/plugin/SetRootDirPropertyMojo.java | 5 +++-- .../java/org/scijava/maven/plugin/SnapshotFinder.java | 5 +++-- .../org/scijava/maven/plugin/VerifyNoSnapshotsMojo.java | 5 +++-- .../scijava/maven/plugin/enforcer/RequireElements.java | 5 +++-- .../maven/plugin/enforcer/RequireReproducibleBuilds.java | 5 +++-- .../maven/plugin/install/AbstractCopyJarsMojo.java | 8 ++++---- .../org/scijava/maven/plugin/install/CopyJarsMojo.java | 8 ++++---- .../scijava/maven/plugin/install/InstallArtifactMojo.java | 8 ++++---- .../java/org/scijava/maven/plugin/util/PomEditor.java | 5 +++-- .../org/scijava/maven/plugin/util/VersionVisitor.java | 5 +++-- .../resources/META-INF/m2e/lifecycle-mapping-metadata.xml | 5 +++-- src/test/java/org/scijava/maven/plugin/PomEditorTest.java | 5 +++-- 85 files changed, 323 insertions(+), 308 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 457b7b9..5892cda 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,6 @@ -Copyright (c) 2014 - 2016, Board of Regents of the University of -Wisconsin-Madison. +Copyright (c) 2014 - 2018, Board of Regents of the University of +Wisconsin-Madison, Broad Institute of MIT and Harvard, Max Planck +Institute of Molecular Cell Biology and Genetics, and KNIME GmbH. All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/pom.xml b/pom.xml index 622d338..fecfdb5 100644 --- a/pom.xml +++ b/pom.xml @@ -96,11 +96,10 @@ bsd_2 Board of Regents of the University of Wisconsin-Madison, Broad Institute of MIT and Harvard, Max Planck -Institute of Molecular Cell Biology and Genetics, University of -Konstanz, and KNIME GmbH. - SciJava Common shared library for SciJava software. +Institute of Molecular Cell Biology and Genetics, and KNIME GmbH. + A plugin for managing SciJava-based projects. 1.8 - 1.6 + 1.6 3.0 2.2.1 2.2 diff --git a/src/it/copy-jars/pom.xml b/src/it/copy-jars/pom.xml index 96262cb..2f993c5 100644 --- a/src/it/copy-jars/pom.xml +++ b/src/it/copy-jars/pom.xml @@ -1,10 +1,10 @@