1 /**
2 * Copyright 2004-2012 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.maven.plugin;
17
18 import org.apache.maven.plugin.AbstractMojo;
19 import org.apache.maven.plugin.MojoExecutionException;
20 import org.apache.maven.plugin.MojoFailureException;
21 import org.apache.maven.project.MavenProject;
22 import org.kuali.maven.common.Extractor;
23
24 /**
25 * Extracts information contained in the pom and exposes it as project properties
26 *
27 * eg major version, scm type, scm url
28 *
29 * @goal extract
30 */
31 public class ExtractorMojo extends AbstractMojo {
32 Extractor extractor = new Extractor();
33
34 /**
35 * The Maven project this plugin runs in.
36 *
37 * @parameter expression="${project}"
38 * @required
39 * @readonly
40 */
41 private MavenProject project;
42
43 /**
44 * The project property where the major version will be stored. eg for a project with a version "1.0.0" this mojo
45 * considers "1.0" to be the major version
46 *
47 * @parameter expression="${extractor.majorVersionProperty}" default-value="extractor.majorVersion"
48 * @required
49 */
50 private String majorVersionProperty;
51
52 /**
53 * The project property where the scm type will be stored eg "svn", "git"
54 *
55 * @parameter expression="${extractor.scmTypeProperty}" default-value="extractor.scmType"
56 * @required
57 */
58 private String scmTypeProperty;
59
60 /**
61 * The project property where the scm url (minus the Maven prefix eg "scm:svn", "scm:git") will be stored
62 *
63 * @parameter expression="${extractor.scmUrlProperty}" default-value="extractor.scmUrl"
64 * @required
65 */
66 private String scmUrlProperty;
67
68 /**
69 * The project property where the Subversion specific tag base will be stored. The logic here examines the scm url
70 * for the last occurrence of "/branches" or "/trunk". It then takes whatever is to the left of that and adds
71 * "/tags"
72 *
73 * @parameter expression="${extractor.svnTagBaseProperty}" default-value="extractor.svnTagBase"
74 * @required
75 */
76 private String svnTagBaseProperty;
77
78 /**
79 * The project property where the Subversion specific branch will be stored. The logic here examines the scm url for
80 * the last occurrence of "/branches" or "/trunk". If it finds the string "/branches" it stores whatever is to the
81 * right of that under the indicated property, if it finds the string "/trunk" it stores "trunk" under the indicated
82 * property
83 *
84 * @parameter expression="${extractor.svnBranchProperty}" default-value="extractor.svnBranch"
85 * @required
86 */
87 private String svnBranchProperty;
88
89 @Override
90 public void execute() throws MojoExecutionException, MojoFailureException {
91 extractor.handleMajorVersion(this, project, majorVersionProperty);
92 extractor.handleScmType(this, project, scmTypeProperty);
93 extractor.handleScmUrl(this, project, scmUrlProperty);
94 extractor.handleSVNTagBase(this, project, svnTagBaseProperty);
95 extractor.handleSVNBranch(this, project, svnBranchProperty);
96 }
97
98 public MavenProject getProject() {
99 return project;
100 }
101
102 public void setProject(MavenProject project) {
103 this.project = project;
104 }
105
106 public String getMajorVersionProperty() {
107 return majorVersionProperty;
108 }
109
110 public void setMajorVersionProperty(String majorVersionProperty) {
111 this.majorVersionProperty = majorVersionProperty;
112 }
113
114 public String getScmTypeProperty() {
115 return scmTypeProperty;
116 }
117
118 public void setScmTypeProperty(String scmTypeProperty) {
119 this.scmTypeProperty = scmTypeProperty;
120 }
121
122 public String getScmUrlProperty() {
123 return scmUrlProperty;
124 }
125
126 public void setScmUrlProperty(String scmUrlProperty) {
127 this.scmUrlProperty = scmUrlProperty;
128 }
129
130 public String getSvnTagBaseProperty() {
131 return svnTagBaseProperty;
132 }
133
134 public void setSvnTagBaseProperty(String scmTagBaseProperty) {
135 this.svnTagBaseProperty = scmTagBaseProperty;
136 }
137
138 public String getSvnBranchProperty() {
139 return svnBranchProperty;
140 }
141
142 public void setSvnBranchProperty(String svnBranchProperty) {
143 this.svnBranchProperty = svnBranchProperty;
144 }
145 }