Skip to content

Commit cf68e4f

Browse files
authored
Merge pull request #5 from git-commit-id/remove-plexus
#3: Remove org.sonatype.plexus dependency
2 parents fc636fa + 8682a3b commit cf68e4f

File tree

4 files changed

+52
-28
lines changed

4 files changed

+52
-28
lines changed

pom.xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@
185185
<artifactId>joda-time</artifactId>
186186
<version>2.10.10</version>
187187
</dependency>
188-
<!-- plexus build -->
189-
<dependency>
190-
<groupId>org.sonatype.plexus</groupId>
191-
<artifactId>plexus-build-api</artifactId>
192-
<version>0.0.7</version>
193-
</dependency>
194188
<dependency>
195189
<groupId>com.google.code.findbugs</groupId>
196190
<artifactId>jsr305</artifactId>
@@ -219,18 +213,6 @@
219213
<version>${junit.version}</version>
220214
<scope>test</scope>
221215
</dependency>
222-
<dependency>
223-
<groupId>org.codehaus.plexus</groupId>
224-
<artifactId>plexus-utils</artifactId>
225-
<version>3.3.0</version>
226-
<scope>test</scope>
227-
</dependency>
228-
<dependency>
229-
<groupId>org.codehaus.plexus</groupId>
230-
<artifactId>plexus-container-default</artifactId>
231-
<version>2.1.0</version>
232-
<scope>test</scope>
233-
</dependency>
234216
<dependency>
235217
<groupId>org.assertj</groupId>
236218
<artifactId>assertj-core</artifactId>

src/main/java/pl/project13/core/PropertiesFileGenerator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
package pl.project13.core;
1919

2020
import nu.studer.java.util.OrderedProperties;
21-
import org.sonatype.plexus.build.incremental.BuildContext;
2221
import pl.project13.core.log.LoggerBridge;
22+
import pl.project13.core.util.BuildFileChangeListener;
2323
import pl.project13.core.util.JsonManager;
2424
import pl.project13.core.util.PropertyManager;
2525

@@ -33,14 +33,14 @@
3333
public class PropertiesFileGenerator {
3434

3535
private LoggerBridge log;
36-
private BuildContext buildContext;
36+
private BuildFileChangeListener buildFileChangeListener;
3737
private String format;
3838
private String prefixDot;
3939
private String projectName;
4040

41-
public PropertiesFileGenerator(LoggerBridge log, BuildContext buildContext, String format, String prefixDot, String projectName) {
41+
public PropertiesFileGenerator(LoggerBridge log, BuildFileChangeListener buildFileChangeListener, String format, String prefixDot, String projectName) {
4242
this.log = log;
43-
this.buildContext = buildContext;
43+
this.buildFileChangeListener = buildFileChangeListener;
4444
this.format = format;
4545
this.prefixDot = prefixDot;
4646
this.projectName = projectName;
@@ -97,8 +97,8 @@ public void maybeGeneratePropertiesFile(@Nonnull Properties localProperties, Fil
9797
throw new RuntimeException("Cannot create custom git properties file: " + gitPropsFile, ex);
9898
}
9999

100-
if (buildContext != null) {
101-
buildContext.refresh(gitPropsFile);
100+
if (buildFileChangeListener != null) {
101+
buildFileChangeListener.changed(gitPropsFile);
102102
}
103103

104104
} else {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* This file is part of git-commit-id-plugin-core by Konrad 'ktoso' Malawski <konrad.malawski@java.pl>
3+
*
4+
* git-commit-id-plugin-core is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* git-commit-id-plugin-core is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with git-commit-id-plugin-core. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package pl.project13.core.util;
19+
20+
import javax.annotation.Nonnull;
21+
import java.io.File;
22+
import java.util.EventListener;
23+
24+
public interface BuildFileChangeListener extends EventListener {
25+
/**
26+
* Event will be fired when then {@link pl.project13.core.PropertiesFileGenerator} changed the output file.
27+
* A client who may want to implement that listener may want to perform other actions.
28+
* E.g.
29+
* {code}
30+
* BuildContext buildContext = ...
31+
* new BuildFileChangeListener() {
32+
* void changed(@Nonnull File file) {
33+
* buildContext.refresh(file);
34+
* }
35+
* }
36+
* {code}
37+
* @param file The output properties File that was changed by the generator
38+
*/
39+
void changed(@Nonnull File file);
40+
}

src/test/java/pl/project13/core/PropertiesFileGeneratorTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
import org.junit.Rule;
2222
import org.junit.Test;
2323
import org.junit.rules.TemporaryFolder;
24-
import org.sonatype.plexus.build.incremental.BuildContext;
25-
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
2624
import pl.project13.core.log.LoggerBridge;
2725
import pl.project13.core.log.StdOutLoggerBridge;
26+
import pl.project13.core.util.BuildFileChangeListener;
2827

2928
import java.io.IOException;
3029
import java.nio.file.Files;
@@ -39,13 +38,16 @@ public class PropertiesFileGeneratorTest {
3938
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
4039

4140
private final LoggerBridge loggerBridge = new StdOutLoggerBridge(false);
42-
private final BuildContext buildContext = new DefaultBuildContext();
4341

4442
private PropertiesFileGenerator propertiesFileGenerator;
4543

4644
@Before
4745
public void setUp() {
48-
propertiesFileGenerator = new PropertiesFileGenerator(loggerBridge, buildContext, "properties", "", "test");
46+
BuildFileChangeListener buildFileChangeListener = file -> {
47+
// Ignore
48+
};
49+
50+
propertiesFileGenerator = new PropertiesFileGenerator(loggerBridge, buildFileChangeListener, "properties", "", "test");
4951
}
5052

5153
@Test

0 commit comments

Comments
 (0)