3434import java .io .File ;
3535import java .io .IOException ;
3636
37- import org .apache .maven .execution .MavenSession ;
38- import org .apache .maven .plugin .MojoExecution ;
3937import org .apache .maven .plugin .MojoExecutionException ;
40- import org .apache .maven .plugin .PluginParameterExpressionEvaluator ;
4138import org .apache .maven .plugins .annotations .Component ;
4239import org .apache .maven .plugins .annotations .Mojo ;
4340import org .apache .maven .plugins .annotations .Parameter ;
5047import org .apache .maven .shared .dependencies .DefaultDependableCoordinate ;
5148import org .apache .maven .shared .dependencies .resolve .DependencyResolver ;
5249import org .apache .maven .shared .dependencies .resolve .DependencyResolverException ;
53- import org .codehaus .plexus .component .configurator .expression .ExpressionEvaluationException ;
54- import org .codehaus .plexus .component .configurator .expression .ExpressionEvaluator ;
5550
5651/**
5752 * Copies .jar artifacts and their dependencies into a SciJava application
7166@ Mojo (name = "copy-jars" , requiresProject = true , requiresOnline = true )
7267public class CopyJarsMojo extends AbstractCopyJarsMojo {
7368
74- /**
75- * Path to the ImageJ.app/ directory to which artifacts are copied.
76- * <p>
77- * If it is not a directory, no .jar files are copied.
78- * </p>
79- */
80- @ Deprecated
81- @ Parameter (property = imagejDirectoryProperty , required = false )
82- private String imagejDirectory ;
83-
84- /**
85- * Path to a SciJava application directory (e.g. ImageJ.app) to which
86- * artifacts are copied.
87- * <p>
88- * If it is not a directory, no .jar files are copied.
89- * </p>
90- */
91- @ Parameter (property = appDirectoryProperty , required = false )
92- private String appDirectory ;
93-
94- /**
95- * The name of the property pointing to the subdirectory (beneath e.g.
96- * {@code jars/} or {@code plugins/}) to which the artifact should be copied.
97- * <p>
98- * If no property of that name exists, no subdirectory will be used.
99- * </p>
100- */
101- @ Deprecated
102- @ Parameter (property = imagejSubdirectoryProperty , required = false )
103- private String imagejSubdirectory ;
104-
105- /**
106- * The name of the property pointing to the subdirectory (beneath e.g.
107- * {@code jars/} or {@code plugins/}) to which the artifact should be copied.
108- * <p>
109- * If no property of that name exists, no subdirectory will be used.
110- * </p>
111- */
112- @ Parameter (property = appSubdirectoryProperty , required = false )
113- private String appSubdirectory ;
114-
115- /**
116- * Whether to delete other versions when copying the files.
117- * <p>
118- * When copying a file and its dependencies to an ImageJ.app/ directory and
119- * there are other versions of the same file, we can warn or delete those
120- * other versions.
121- * </p>
122- */
123- @ Deprecated
124- @ Parameter (property = deleteOtherVersionsProperty )
125- private boolean deleteOtherVersions ;
126-
127- /**
128- * Whether to delete other versions when copying the files.
129- * <p>
130- * When copying a file and its dependencies to an ImageJ.app/ directory and
131- * there are other versions of the same file, we can warn or delete those
132- * other versions.
133- * </p>
134- */
135- @ Deprecated
136- @ Parameter (property = imagejDeleteOtherVersionsPolicyProperty )
137- private OtherVersions imagejDeleteOtherVersionsPolicy ;
138-
139- /**
140- * Whether to delete other versions when copying the files.
141- * <p>
142- * When copying a file and its dependencies to a SciJava application directory
143- * and there are other versions of the same file, we can warn or delete those
144- * other versions.
145- * </p>
146- */
147- @ Parameter (property = deleteOtherVersionsPolicyProperty , defaultValue = "older" )
148- private OtherVersions deleteOtherVersionsPolicy ;
149-
150- /**
151- * If this option is set to <code>true</code>, only the artifact will be
152- * copied - without its dependencies.
153- */
154- @ Parameter (property = ignoreDependenciesProperty , defaultValue = "false" )
155- private boolean ignoreDependencies ;
156-
15769 /**
15870 * Project
15971 */
16072 @ Parameter (defaultValue = "${project}" , required =true , readonly = true )
16173 private MavenProject project ;
16274
163- /**
164- * Session
165- */
166- @ Parameter (defaultValue = "${session}" )
167- private MavenSession session ;
168-
16975 /**
17076 * The dependency resolver to.
17177 */
@@ -176,13 +82,10 @@ public class CopyJarsMojo extends AbstractCopyJarsMojo {
17682
17783 private File appDir ;
17884
179- @ Parameter ( defaultValue = "${mojoExecution}" , readonly = true )
180- MojoExecution mojoExecution ;
181-
18285 @ Override
18386 public void execute () throws MojoExecutionException {
184- // Keep backwards compatibility
185- handleBackwardsCompatibility ();
87+ // Keep backward compatibility
88+ handleBackwardCompatibility ();
18689
18790 if (appDirectory == null ) {
18891 if (hasIJ1Dependency (project )) getLog ().info (
@@ -241,62 +144,4 @@ public void execute() throws MojoExecutionException {
241144 "Couldn't resolve dependencies for artifact: " + e .getMessage (), e );
242145 }
243146 }
244-
245- /**
246- * TODO Javadoc
247- */
248- private void handleBackwardsCompatibility () {
249- ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator (session , mojoExecution );
250-
251- try {
252- // If at least one scijava.* property is set, ignore imagej.* properties
253- if (evaluator .evaluate ("${" + appDirectoryProperty + "}" ) == null &&
254- evaluator .evaluate ("${" + appSubdirectoryProperty + "}" ) == null &&
255- evaluator .evaluate ("${" + deleteOtherVersionsPolicyProperty + "}" ) == null )
256- {
257-
258- // Keep backwards compatibility to delete.other.versions
259- if (evaluator .evaluate ("${" +deleteOtherVersionsProperty +"}" ) != null ) {
260- getLog ().warn ("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '" + deleteOtherVersionsPolicyProperty +"' instead" );
261- deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions .older : OtherVersions .never ;
262- }
263-
264- // Keep backwards compatibility to imagej.app.directory
265- // Use imagejDirectory if it is set (directly or via imagej.app.directory)
266- if (imagejDirectory != null ) {
267- if (evaluator .evaluate ("${" +imagejDirectoryProperty +"}" ) == null ) {
268- getLog ().warn ("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead" );
269- } else {
270- getLog ().warn ("Property '" + imagejDirectoryProperty + "' is deprecated. Use '" + appDirectoryProperty +"' instead" );
271- }
272- appDirectory = imagejDirectory ;
273- }
274-
275- // Keep backwards compatibility to imagej.app.subdirectory
276- // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory)
277- if (imagejSubdirectory != null ) {
278- if (evaluator .evaluate ("${" +imagejSubdirectoryProperty +"}" ) == null ) {
279- getLog ().warn ("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead" );
280- } else {
281- getLog ().warn ("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '" + appSubdirectoryProperty +"' instead" );
282- }
283- appSubdirectory = imagejSubdirectory ;
284- }
285-
286- // Keep backwards compatibility to imagej.deleteOtherVersions
287- // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions)
288- if (imagejDeleteOtherVersionsPolicy != null ) {
289- if (evaluator .evaluate ("${" +imagejDeleteOtherVersionsPolicyProperty +"}" ) == null ) {
290- getLog ().warn ("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead" );
291- } else {
292- getLog ().warn ("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '" + deleteOtherVersionsPolicyProperty +"' instead" );
293- }
294- deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy ;
295- }
296- }
297- }
298- catch (ExpressionEvaluationException e ) {
299- getLog ().warn (e );
300- }
301- }
302147}
0 commit comments