Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ScmPublishInventoryMojo |
|
| 2.0;2 |
1 | package org.apache.maven.plugins.scmpublish; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import java.io.File; | |
23 | import java.util.List; | |
24 | ||
25 | import org.apache.commons.io.FileUtils; | |
26 | import org.apache.maven.plugin.MojoExecutionException; | |
27 | import org.apache.maven.plugin.MojoFailureException; | |
28 | import org.apache.maven.plugins.annotations.LifecyclePhase; | |
29 | import org.apache.maven.plugins.annotations.Mojo; | |
30 | ||
31 | /** | |
32 | * Prepare a directory for version-managed site generation. This checks out the specified directory from the SCM, | |
33 | * then takes inventory of all the resulting files then deletes every files. | |
34 | * This inventory then allows the 'publish' target to tee up deletions | |
35 | * as well as modifications and additions. | |
36 | * | |
37 | * There's an assumption here that an entire directory in SCM is dedicated to | |
38 | * the publication process for this project. In the aggregate case, this is going to take some doing. | |
39 | * | |
40 | * If we allow this to be non-aggregate, then each module has to configure pathnames, which would be a pain. So | |
41 | * we assume that in an aggregate project this runs once, at the top -- then all of the projects site-deploy | |
42 | * into the file: url this creates. | |
43 | * | |
44 | * | |
45 | * TODO: we want | |
46 | * multiple includes/excludes, but the scm API doesn't go there. | |
47 | * @deprecated superseded by publish-scm which does the same in on step only and has more features | |
48 | */ | |
49 | @Mojo( name = "prepare", defaultPhase = LifecyclePhase.PRE_SITE, aggregator = true ) | |
50 | 0 | public class ScmPublishInventoryMojo |
51 | extends AbstractScmPublishMojo | |
52 | { | |
53 | /** | |
54 | * Clear out the data, so we can tell what's left after the run of the site plugin. | |
55 | * For now, don't bother with deleting empty directories. They are fairly harmless, | |
56 | * and leaving them around allows this to work with pre-1.7 svn. | |
57 | */ | |
58 | private void deleteContent( List<File> inventory ) | |
59 | { | |
60 | 0 | for ( File f : inventory ) |
61 | { | |
62 | 0 | if ( f.isFile() ) |
63 | { | |
64 | 0 | FileUtils.deleteQuietly( f ); |
65 | } | |
66 | } | |
67 | 0 | } |
68 | ||
69 | public void scmPublishExecute() | |
70 | throws MojoExecutionException, MojoFailureException | |
71 | { | |
72 | 0 | checkoutExisting(); |
73 | ||
74 | 0 | List<File> inventory = |
75 | ScmPublishInventory.listInventoryFiles( checkoutDirectory, scmProvider.getScmSpecificFilename() ); | |
76 | ||
77 | 0 | ScmPublishInventory.writeInventory( inventory, inventoryFile ); |
78 | ||
79 | 0 | deleteContent( inventory ); |
80 | 0 | } |
81 | } |