Skip to content

#3: Remove org.sonatype.plexus dependency #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@
<artifactId>joda-time</artifactId>
<version>2.10.10</version>
</dependency>
<!-- plexus build -->
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
Expand Down Expand Up @@ -219,18 +213,6 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/pl/project13/core/PropertiesFileGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package pl.project13.core;

import nu.studer.java.util.OrderedProperties;
import org.sonatype.plexus.build.incremental.BuildContext;
import pl.project13.core.log.LoggerBridge;
import pl.project13.core.util.BuildFileChangeListener;
import pl.project13.core.util.JsonManager;
import pl.project13.core.util.PropertyManager;

Expand All @@ -33,14 +33,14 @@
public class PropertiesFileGenerator {

private LoggerBridge log;
private BuildContext buildContext;
private BuildFileChangeListener buildFileChangeListener;
private String format;
private String prefixDot;
private String projectName;

public PropertiesFileGenerator(LoggerBridge log, BuildContext buildContext, String format, String prefixDot, String projectName) {
public PropertiesFileGenerator(LoggerBridge log, BuildFileChangeListener buildFileChangeListener, String format, String prefixDot, String projectName) {
this.log = log;
this.buildContext = buildContext;
this.buildFileChangeListener = buildFileChangeListener;
this.format = format;
this.prefixDot = prefixDot;
this.projectName = projectName;
Expand Down Expand Up @@ -97,8 +97,8 @@ public void maybeGeneratePropertiesFile(@Nonnull Properties localProperties, Fil
throw new RuntimeException("Cannot create custom git properties file: " + gitPropsFile, ex);
}

if (buildContext != null) {
buildContext.refresh(gitPropsFile);
if (buildFileChangeListener != null) {
buildFileChangeListener.changed(gitPropsFile);
}

} else {
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/pl/project13/core/util/BuildFileChangeListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file is part of git-commit-id-plugin-core by Konrad 'ktoso' Malawski <konrad.malawski@java.pl>
*
* git-commit-id-plugin-core is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* git-commit-id-plugin-core is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with git-commit-id-plugin-core. If not, see <http://www.gnu.org/licenses/>.
*/

package pl.project13.core.util;

import javax.annotation.Nonnull;
import java.io.File;
import java.util.EventListener;

public interface BuildFileChangeListener extends EventListener {
/**
* Event will be fired when then {@link pl.project13.core.PropertiesFileGenerator} changed the output file.
* A client who may want to implement that listener may want to perform other actions.
* E.g.
* {code}
* BuildContext buildContext = ...
* new BuildFileChangeListener() {
* void changed(@Nonnull File file) {
* buildContext.refresh(file);
* }
* }
* {code}
* @param file The output properties File that was changed by the generator
*/
void changed(@Nonnull File file);
}
10 changes: 6 additions & 4 deletions src/test/java/pl/project13/core/PropertiesFileGeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonatype.plexus.build.incremental.BuildContext;
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
import pl.project13.core.log.LoggerBridge;
import pl.project13.core.log.StdOutLoggerBridge;
import pl.project13.core.util.BuildFileChangeListener;

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

private final LoggerBridge loggerBridge = new StdOutLoggerBridge(false);
private final BuildContext buildContext = new DefaultBuildContext();

private PropertiesFileGenerator propertiesFileGenerator;

@Before
public void setUp() {
propertiesFileGenerator = new PropertiesFileGenerator(loggerBridge, buildContext, "properties", "", "test");
BuildFileChangeListener buildFileChangeListener = file -> {
// Ignore
};

propertiesFileGenerator = new PropertiesFileGenerator(loggerBridge, buildFileChangeListener, "properties", "", "test");
}

@Test
Expand Down