88import okio .ByteString ;
99import org .apache .maven .plugin .AbstractMojo ;
1010import org .apache .maven .plugin .MojoExecutionException ;
11+ import org .apache .maven .plugins .annotations .Component ;
1112import org .apache .maven .plugins .annotations .LifecyclePhase ;
1213import org .apache .maven .plugins .annotations .Mojo ;
1314import org .apache .maven .plugins .annotations .Parameter ;
15+ import org .sonatype .plexus .components .sec .dispatcher .SecDispatcher ;
16+ import org .sonatype .plexus .components .sec .dispatcher .SecDispatcherException ;
1417import retrofit .RestAdapter ;
1518import retrofit .RetrofitError ;
1619import retrofit .client .Response ;
2932 * Rob logger
3033 *
3134 */
32- @ Mojo ( name = "rob" )
33- public class RobMojo extends AbstractMojo
35+ @ Mojo ( name = "logs" , requiresProject = false )
36+ public class RobLogsMojo extends AbstractMojo
3437{
3538 @ Parameter (property = "rob.repo" , required = true )
3639 private String repository ;
@@ -50,7 +53,7 @@ public class RobMojo extends AbstractMojo
5053 @ Parameter (property = "rob.branch" , defaultValue = "development" )
5154 private String branch ;
5255
53- @ Parameter (property = "rob.file" , defaultValue = "changelog.txt" )
56+ @ Parameter (property = "rob.file" , defaultValue = "./ changelog.txt" )
5457 private String filePath ;
5558
5659 @ Parameter (property = "rob.key" , required = true )
@@ -65,8 +68,11 @@ public class RobMojo extends AbstractMojo
6568 @ Parameter (readonly = true , defaultValue = "${project.build.directory}" )
6669 protected File targetDirectory ;
6770
68- @ Parameter (readonly = true , defaultValue = "${timestamp}" )
69- private String currentTime ;
71+ /**
72+ * @since 1.1.0
73+ */
74+ @ Component
75+ private SecDispatcher securityDispatcher ;
7076
7177 private List <String > commitMessages = new LinkedList <>();
7278 private List <String > jiraMessages = new LinkedList <>();
@@ -179,7 +185,7 @@ private boolean initDateParams() {
179185 endDate = LocalDate .parse (endDateStr , DateTimeFormatter .ISO_LOCAL_DATE );
180186
181187 } else {
182- endDate = LocalDate .parse ( currentTime , DateTimeFormatter . ISO_LOCAL_DATE );
188+ endDate = LocalDate .now ( );
183189 }
184190
185191 if (startDateStr != null && startDateStr .length () > 0 ) {
@@ -212,7 +218,13 @@ private void generateFile() {
212218 writeToFile (buffer , "\n \n Uncategorised messages:\n " , otherMessages );
213219
214220 try {
215- File file = new File (targetDirectory , filePath );
221+ File file ;
222+ if (targetDirectory != null && targetDirectory .exists ()){
223+ file = new File (targetDirectory , filePath );
224+ } else {
225+ file = new File ( filePath );
226+ }
227+
216228 file .createNewFile ();
217229 buffer .writeTo (new FileOutputStream ( file ));
218230
@@ -231,4 +243,14 @@ private void writeToFile(Buffer buffer, String title, List<String> content) {
231243 }
232244 }
233245 }
246+
247+ protected String decrypt (String encoded ) throws MojoExecutionException {
248+ try {
249+ return securityDispatcher .decrypt ( encoded );
250+
251+ } catch ( SecDispatcherException e ) {
252+ getLog ().error ( "error using security dispatcher: " + e .getMessage (), e );
253+ throw new MojoExecutionException ( "error using security dispatcher: " + e .getMessage (), e );
254+ }
255+ }
234256}
0 commit comments