This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #3 from marwin1991/generate_empty_changelog_with_g…
…itkeep Implementing empty changelog
- Loading branch information
Showing
7 changed files
with
91 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -82,3 +82,5 @@ TODO | |
|
||
|
||
|
||
Requirements: | ||
- set up the JAVA_HOME system variable |
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,7 @@ | ||
title: Added maven command to initilize project with changelog/unreleased directory and empty CHANGELOG.md | ||
authors: | ||
nick: Glukasze | ||
url: https://github.com/Glukasze | ||
type: added # [added/changed/deprecated/removed/fixed/security] | ||
merge_request: 3 | ||
|
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
62 changes: 62 additions & 0 deletions
62
src/main/java/com/github/marwin1991/keep_changelog/InitProjectMojo.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,62 @@ | ||
package com.github.marwin1991.keep_changelog; | ||
|
||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugins.annotations.LifecyclePhase; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
@Mojo(name = "init", defaultPhase = LifecyclePhase.NONE) | ||
public class InitProjectMojo extends AbstractMojo { | ||
|
||
private static final String GIT_KEEP = ".gitkeep"; | ||
|
||
@Parameter(defaultValue = "CHANGELOG.md", property = "finalChangelogName") | ||
private String finalChangelogName; | ||
|
||
@Parameter(defaultValue = "changelog", property = "yamlFilesDirectory") | ||
private String yamlFilesDirectory; | ||
|
||
@Parameter(defaultValue = "unreleased", property = "unreleasedVersionDirectory") | ||
private String unreleasedVersionDirectory; | ||
|
||
@Override | ||
public void execute() { | ||
getLog().info("Initialize project for keep-changelog maven plugin"); | ||
generateChangelog(finalChangelogName); | ||
generateChangelogDirUnreleasedDirGitKeep(yamlFilesDirectory + "/" + unreleasedVersionDirectory + "/"); | ||
getLog().info("Initialize project successful"); | ||
} | ||
|
||
public void generateChangelog(String path) { | ||
|
||
try { | ||
File changelog = new File(path); | ||
if (changelog.createNewFile()) { | ||
getLog().info("Created: " + changelog.getName()); | ||
} else { | ||
getLog().warn(changelog.getName() + " already exists."); | ||
} | ||
} catch (IOException e) { | ||
getLog().error("An error occurred while creating empty changelog."); | ||
} | ||
} | ||
|
||
public void generateChangelogDirUnreleasedDirGitKeep(String path) { | ||
|
||
try { | ||
File gitKeep = new File(path + GIT_KEEP); | ||
if (gitKeep.createNewFile()) { | ||
getLog().info("Created: " + gitKeep.getName()); | ||
} else { | ||
getLog().warn(gitKeep.getName() + " already exists."); | ||
} | ||
} catch (IOException e) { | ||
getLog().error("An error occurred while creating empty .gitkeep."); | ||
} | ||
} | ||
|
||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/github/marwin1991/keep_changelog/test/TestInitProject.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,11 @@ | ||
package com.github.marwin1991.keep_changelog.test; | ||
|
||
import com.github.marwin1991.keep_changelog.InitProjectMojo; | ||
|
||
public class TestInitProject { | ||
|
||
public static void main(String[] args) { | ||
new InitProjectMojo().generateChangelog("CHANGELOG.md"); | ||
new InitProjectMojo().generateChangelogDirUnreleasedDirGitKeep("changelog/unreleased/"); | ||
} | ||
} |