Skip to content

Commit 735b046

Browse files
author
Benoit Billington
committed
Ability to run rob:logs without a project - Releave version 1.1.0
1 parent d0067bd commit 735b046

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>be.billington</groupId>
88
<artifactId>rob-maven-plugin</artifactId>
9-
<version>1.0.1</version>
9+
<version>1.1.0</version>
1010

1111
<packaging>maven-plugin</packaging>
1212

@@ -30,6 +30,12 @@
3030
<version>${maven.version}</version>
3131
</dependency>
3232

33+
<dependency>
34+
<groupId>org.sonatype.plexus</groupId>
35+
<artifactId>plexus-sec-dispatcher</artifactId>
36+
<version>1.4</version>
37+
</dependency>
38+
3339
<dependency>
3440
<groupId>com.squareup.retrofit</groupId>
3541
<artifactId>retrofit</artifactId>
@@ -72,6 +78,7 @@
7278
<artifactId>maven-plugin-plugin</artifactId>
7379
<version>${mavenPluginPluginVersion}</version>
7480
<configuration>
81+
<goalPrefix>rob</goalPrefix>
7582
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
7683
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
7784
</configuration>

src/main/java/be/billington/rob/RobMojo.java renamed to src/main/java/be/billington/rob/RobLogsMojo.java

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
import okio.ByteString;
99
import org.apache.maven.plugin.AbstractMojo;
1010
import org.apache.maven.plugin.MojoExecutionException;
11+
import org.apache.maven.plugins.annotations.Component;
1112
import org.apache.maven.plugins.annotations.LifecyclePhase;
1213
import org.apache.maven.plugins.annotations.Mojo;
1314
import org.apache.maven.plugins.annotations.Parameter;
15+
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
16+
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException;
1417
import retrofit.RestAdapter;
1518
import retrofit.RetrofitError;
1619
import retrofit.client.Response;
@@ -29,8 +32,8 @@
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\nUncategorised 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

Comments
 (0)