-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from ADI10HERO/write-version
feat: add writeVersion for maven project
- Loading branch information
Showing
9 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/io/jenkins/plugins/conventionalcommits/utils/WriteVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.jenkins.plugins.conventionalcommits.utils; | ||
|
||
import com.github.zafarkhaja.semver.Version; | ||
import io.jenkins.plugins.conventionalcommits.process.DefaultProcessHelper; | ||
import io.jenkins.plugins.conventionalcommits.process.ProcessHelper; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.logging.Level; | ||
|
||
/** Class to write back the calculated next semantic version into the config file of a project. */ | ||
public class WriteVersion { | ||
private ProcessHelper processHelper; | ||
|
||
public void setProcessHelper(ProcessHelper processHelper) { | ||
this.processHelper = processHelper; | ||
} | ||
|
||
/** | ||
* Writes next semantic version in a file. | ||
* | ||
* @param nextVersion The project's calculated next semantic version. | ||
* @param directory Directory of the project | ||
* @throws IOException If an error occurs while reading/writing files. | ||
* @throws InterruptedException If an error occurs while executing command using processHelper. | ||
*/ | ||
public void write(Version nextVersion, File directory) throws IOException, InterruptedException { | ||
|
||
ProjectType projectType = ProjectTypeFactory.getProjectType(directory); | ||
|
||
if (projectType != null) { | ||
if (processHelper == null) { | ||
processHelper = new DefaultProcessHelper(); | ||
} | ||
projectType.writeVersion(directory, nextVersion, processHelper); | ||
} else { | ||
LogUtils logger = new LogUtils(); | ||
logger.log(Level.INFO, Level.INFO, Level.FINE, Level.FINE, true, "Could not write to file"); | ||
} | ||
} | ||
} |