Skip to content

Commit

Permalink
[core] handle quite mode in cli, maven, gradle. Resolves #768
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Feb 20, 2022
1 parent e9f041b commit f1c73e2
Show file tree
Hide file tree
Showing 27 changed files with 211 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ abstract class AbstractCommand extends BaseCommand implements Callable<Integer>
protected abstract Main parent();

public Integer call() {
Banner.display(parent().out);

System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "error");
setup();

try {
execute();
Expand All @@ -52,6 +50,12 @@ public Integer call() {
return 0;
}

protected void setup() {
Banner.display(parent().out);

System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "error");
}

protected void printDetails(Throwable throwable, String message, Colorizer colorizer) {
if (throwable == null) return;
String myMessage = throwable.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.List;
import java.util.concurrent.Callable;

import static org.jreleaser.util.JReleaserOutput.JRELEASER_QUIET;
import static org.jreleaser.util.StringUtils.isNotBlank;

/**
Expand Down Expand Up @@ -58,8 +59,9 @@ abstract class AbstractLoggingCommand extends AbstractCommand implements Callabl
@CommandLine.Option(names = {"-od", "--output-directory"})
Path outputdir;

protected void initLogger() {
ColorizedJReleaserLoggerAdapter.Level level = ColorizedJReleaserLoggerAdapter.Level.INFO;
protected ColorizedJReleaserLoggerAdapter.Level level = ColorizedJReleaserLoggerAdapter.Level.INFO;

protected void setup() {
if (debug) {
level = ColorizedJReleaserLoggerAdapter.Level.DEBUG;
System.setProperty("org.slf4j.simpleLogger.org.jreleaser", "debug");
Expand All @@ -72,8 +74,13 @@ protected void initLogger() {
} else if (quiet) {
level = ColorizedJReleaserLoggerAdapter.Level.ERROR;
System.setProperty("org.slf4j.simpleLogger.org.jreleaser", "error");
System.setProperty(JRELEASER_QUIET, "true");
}

Banner.display(parent().out);
}

protected void initLogger() {
logger = new ColorizedJReleaserLoggerAdapter(createTracer(), parent().out, level);
}

Expand Down
8 changes: 5 additions & 3 deletions apps/jreleaser/src/main/java/org/jreleaser/cli/Banner.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.jreleaser.cli;

import org.jreleaser.util.JReleaserOutput;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -57,7 +59,7 @@ public static void display(PrintWriter out) {
File parent = new File(jreleaserDir, "/.jreleaser/caches");
File markerFile = getMarkerFile(parent, b);
if (!markerFile.exists()) {
out.println(b.banner);
if (!JReleaserOutput.isQuiet()) out.println(b.banner);
markerFile.getParentFile().mkdirs();
PrintStream fout = new PrintStream(new FileOutputStream(markerFile));
fout.println("1");
Expand All @@ -67,12 +69,12 @@ public static void display(PrintWriter out) {
try {
int count = Integer.parseInt(readQuietly(markerFile));
if (count < 3) {
out.println(b.banner);
if (!JReleaserOutput.isQuiet()) out.println(b.banner);
}
writeQuietly(markerFile, (count + 1) + "");
} catch (NumberFormatException e) {
writeQuietly(markerFile, "1");
out.println(b.banner);
if (!JReleaserOutput.isQuiet()) out.println(b.banner);
}
}
} catch (IOException ignored) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.TreeSet;
import java.util.stream.Collectors;

import static org.jreleaser.util.JReleaserOutput.nag;
import static org.jreleaser.util.StringUtils.isBlank;
import static org.jreleaser.util.StringUtils.isNotBlank;
import static org.jreleaser.util.StringUtils.toSafeRegexPattern;
Expand Down Expand Up @@ -217,7 +218,7 @@ public String getChange() {

@Deprecated
public void setChange(String change) {
System.out.println("changelog.change has been deprecated since 0.6.0 and will be removed in the future. Use changelog.format instead");
nag("changelog.change has been deprecated since 0.6.0 and will be removed in the future. Use changelog.format instead");
this.format = change;
}

Expand Down Expand Up @@ -271,7 +272,7 @@ public void setContributors(Contributors contributors) {

@Deprecated
public void setHideUncategorized(boolean hideUncategorized) {
System.out.println("changelog.hideUncategorized has been deprecated since 0.6.0 and will be removed in the future. Use changelog.hide.uncategorized instead");
nag("changelog.hideUncategorized has been deprecated since 0.6.0 and will be removed in the future. Use changelog.hide.uncategorized instead");
this.hide.uncategorized = hideUncategorized;
}

Expand Down Expand Up @@ -328,13 +329,6 @@ public static class Category implements Domain {
if (null == o2.getOrder()) return -1;
return o1.getOrder().compareTo(o2.getOrder());
};

public static Set<Category> sort(Set<Category> categories) {
TreeSet<Category> tmp = new TreeSet<>(ORDER);
tmp.addAll(categories);
return tmp;
}

private final Set<String> labels = new LinkedHashSet<>();
private String key;
private String title;
Expand Down Expand Up @@ -421,6 +415,12 @@ public int hashCode() {
return Objects.hash(title);
}

public static Set<Category> sort(Set<Category> categories) {
TreeSet<Category> tmp = new TreeSet<>(ORDER);
tmp.addAll(categories);
return tmp;
}

public static Category of(String key, String title, String format, String... labels) {
Category category = new Category();
category.key = key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import static org.jreleaser.util.Constants.KEY_DISTRIBUTION_NAME;
import static org.jreleaser.util.Constants.KEY_DISTRIBUTION_TAGS_BY_COMMA;
import static org.jreleaser.util.Constants.KEY_DISTRIBUTION_TAGS_BY_SPACE;
import static org.jreleaser.util.JReleaserOutput.nag;
import static org.jreleaser.util.MustacheUtils.applyTemplates;
import static org.jreleaser.util.StringUtils.isBlank;
import static org.jreleaser.util.StringUtils.isNotBlank;
Expand Down Expand Up @@ -209,7 +210,7 @@ public void setExecutable(Executable executable) {

@Deprecated
public void setExecutableExtension(String executableExtension) {
System.out.println("executableExtension has been deprecated since 1.0.0-M2 and will be removed in the future. Use executable.windowsExtension instead");
nag("executableExtension has been deprecated since 1.0.0-M2 and will be removed in the future. Use executable.windowsExtension instead");
this.executable.setWindowsExtension(executableExtension);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Map;
import java.util.Set;

import static org.jreleaser.util.JReleaserOutput.nag;
import static org.jreleaser.util.MustacheUtils.applyTemplates;
import static org.jreleaser.util.StringUtils.getClassNameForLowerCaseHyphenSeparatedName;
import static org.jreleaser.util.StringUtils.isBlank;
Expand Down Expand Up @@ -398,85 +399,85 @@ public void setIssueTrackerUrl(String issueTrackerUrl) {

@Deprecated
public String getRepoUrlFormat() {
System.out.println("getRepoUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getRepoUrl() instead");
nag("getRepoUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getRepoUrl() instead");
return repoUrl;
}

@Deprecated
public void setRepoUrlFormat(String repoUrl) {
System.out.println("setRepoUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setRepoUrl() instead");
nag("setRepoUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setRepoUrl() instead");
this.repoUrl = repoUrl;
}

@Deprecated
public String getRepoCloneUrlFormat() {
System.out.println("getRepoCloneUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getRepoCloneUrl() instead");
nag("getRepoCloneUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getRepoCloneUrl() instead");
return repoCloneUrl;
}

@Deprecated
public void setRepoCloneUrlFormat(String repoCloneUrl) {
System.out.println("setRepoCloneUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setRepoCloneUrl() instead");
nag("setRepoCloneUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setRepoCloneUrl() instead");
this.repoCloneUrl = repoCloneUrl;
}

@Deprecated
public String getCommitUrlFormat() {
System.out.println("getCommitUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getCommitUrl() instead");
nag("getCommitUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getCommitUrl() instead");
return commitUrl;
}

@Deprecated
public void setCommitUrlFormat(String commitUrl) {
System.out.println("setCommitUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setCommitUrl() instead");
nag("setCommitUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setCommitUrl() instead");
this.commitUrl = commitUrl;
}

@Deprecated
public String getDownloadUrlFormat() {
System.out.println("getDownloadUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getDownloadUrl() instead");
nag("getDownloadUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getDownloadUrl() instead");
return downloadUrl;
}

@Deprecated
public void setDownloadUrlFormat(String downloadUrl) {
System.out.println("setDownloadUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setDownloadUrl() instead");
nag("setDownloadUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setDownloadUrl() instead");
this.downloadUrl = downloadUrl;
}

@Deprecated
public String getReleaseNotesUrlFormat() {
System.out.println("getReleaseNotesUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getReleaseNotesUrl() instead");
nag("getReleaseNotesUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getReleaseNotesUrl() instead");
return releaseNotesUrl;
}

@Deprecated
public void setReleaseNotesUrlFormat(String releaseNotesUrl) {
System.out.println("setReleaseNotesUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setReleaseNotesUrl() instead");
nag("setReleaseNotesUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setReleaseNotesUrl() instead");
this.releaseNotesUrl = releaseNotesUrl;
}

@Deprecated
public String getLatestReleaseUrlFormat() {
System.out.println("getLatestReleaseUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getLatestReleaseUrl() instead");
nag("getLatestReleaseUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getLatestReleaseUrl() instead");
return latestReleaseUrl;
}

@Deprecated
public void setLatestReleaseUrlFormat(String latestReleaseUrl) {
System.out.println("setLatestReleaseUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setLatestReleaseUrl() instead");
nag("setLatestReleaseUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setLatestReleaseUrl() instead");
this.latestReleaseUrl = latestReleaseUrl;
}

@Deprecated
public String getIssueTrackerUrlFormat() {
System.out.println("getIssueTrackerUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getIssueTrackerUrl() instead");
nag("getIssueTrackerUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use getIssueTrackerUrl() instead");
return issueTrackerUrl;
}

@Deprecated
public void setIssueTrackerUrlFormat(String issueTrackerUrl) {
System.out.println("setIssueTrackerUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setIssueTrackerUrl() instead");
nag("setIssueTrackerUrlFormat() has been deprecated since 0.5.0 and will be removed in the future. Use setIssueTrackerUrl() instead");
this.issueTrackerUrl = issueTrackerUrl;
}

Expand Down Expand Up @@ -624,7 +625,7 @@ public void setUpdate(Update update) {

@Deprecated
public void setUpdateSections(Set<UpdateSection> updateSections) {
System.out.println("updateSections has been deprecated since 1.0.0-M2 and will be removed in the future. Use update.sections instead");
nag("updateSections has been deprecated since 1.0.0-M2 and will be removed in the future. Use update.sections instead");
this.update.setSections(updateSections);
}

Expand Down Expand Up @@ -873,7 +874,7 @@ public Update() {
}

public Update(Boolean enabled) {
System.out.println("update has been deprecated since 1.0.0-M2 and will be removed in the future. Use update.enabled instead");
nag("update has been deprecated since 1.0.0-M2 and will be removed in the future. Use update.enabled instead");
this.enabled = enabled;
}

Expand Down Expand Up @@ -920,7 +921,7 @@ public Prerelease() {
}

public Prerelease(Boolean enabled) {
System.out.println("prerelease has been deprecated since 0.7.0 and will be removed in the future. Use prerelease.enabled instead");
nag("prerelease has been deprecated since 0.7.0 and will be removed in the future. Use prerelease.enabled instead");
this.enabled = enabled;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static java.nio.file.FileVisitResult.CONTINUE;
import static java.nio.file.FileVisitResult.SKIP_SUBTREE;
import static java.nio.file.Files.exists;
import static org.jreleaser.util.JReleaserOutput.nag;
import static org.jreleaser.util.StringUtils.isBlank;
import static org.jreleaser.util.StringUtils.isNotBlank;

Expand Down Expand Up @@ -220,7 +221,7 @@ public String getInclude() {

@Deprecated
public void setInclude(String include) {
System.out.println("glob.include has been deprecated since 0.6.0 and will be removed in the future. Use glob.pattern instead");
nag("glob.include has been deprecated since 0.6.0 and will be removed in the future. Use glob.pattern instead");
this.include = include;
}

Expand All @@ -230,7 +231,7 @@ public String getExclude() {

@Deprecated
public void setExclude(String exclude) {
System.out.println("glob.exclude has been deprecated since 0.6.0 and will be removed in the future. Use glob.pattern instead");
nag("glob.exclude has been deprecated since 0.6.0 and will be removed in the future. Use glob.pattern instead");
this.exclude = exclude;
}

Expand All @@ -240,7 +241,7 @@ public Boolean isRecursive() {

@Deprecated
public void setRecursive(Boolean recursive) {
System.out.println("glob.recursive has been deprecated since 0.6.0 and will be removed in the future. Use glob.pattern instead");
nag("glob.recursive has been deprecated since 0.6.0 and will be removed in the future. Use glob.pattern instead");
this.recursive = recursive;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import static org.jreleaser.util.Constants.HIDE;
import static org.jreleaser.util.Constants.UNSET;
import static org.jreleaser.util.JReleaserOutput.nag;
import static org.jreleaser.util.StringUtils.isNotBlank;

/**
Expand Down Expand Up @@ -86,13 +87,13 @@ public void setPassword(String password) {

@Deprecated
public String getTarget() {
System.out.println("http.target has been deprecated since 0.6.0 and will be removed in the future. Use http.uploadUrl instead");
nag("http.target has been deprecated since 0.6.0 and will be removed in the future. Use http.uploadUrl instead");
return getUploadUrl();
}

@Deprecated
public void setTarget(String target) {
System.out.println("http.target has been deprecated since 0.6.0 and will be removed in the future. Use http.uploadUrl instead");
nag("http.target has been deprecated since 0.6.0 and will be removed in the future. Use http.uploadUrl instead");
setUploadUrl(target);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.List;
import java.util.Map;

import static org.jreleaser.util.JReleaserOutput.nag;
import static org.jreleaser.util.MustacheUtils.applyTemplates;
import static org.jreleaser.util.StringUtils.getClassNameForLowerCaseHyphenSeparatedName;
import static org.jreleaser.util.StringUtils.isBlank;
Expand Down Expand Up @@ -170,7 +171,7 @@ public String getSnapshotPattern() {

@Deprecated
public void setSnapshotPattern(String snapshotPattern) {
System.out.println("project.snapshotPattern has been deprecated since 0.6.0 and will be removed in the future. Use project.snapshot.pattern instead");
nag("project.snapshotPattern has been deprecated since 0.6.0 and will be removed in the future. Use project.snapshot.pattern instead");
this.snapshot.setPattern(snapshotPattern);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
package org.jreleaser.model;

import org.jreleaser.util.Env;
import org.jreleaser.util.JReleaserOutput;

import java.util.Map;

import static org.jreleaser.model.Sdkman.SDKMAN_CONSUMER_KEY;
import static org.jreleaser.model.Sdkman.SDKMAN_CONSUMER_TOKEN;
import static org.jreleaser.util.Constants.HIDE;
import static org.jreleaser.util.Constants.UNSET;
import static org.jreleaser.util.JReleaserOutput.nag;
import static org.jreleaser.util.StringUtils.isNotBlank;

/**
Expand Down Expand Up @@ -130,7 +132,7 @@ public boolean isMajor() {

@Deprecated
public void setMajor(boolean major) {
System.out.println("announce.sdkman.major has been deprecated since 0.6.0 and will be removed in the future. Use announce.sdkman.command instead");
nag("announce.sdkman.major has been deprecated since 0.6.0 and will be removed in the future. Use announce.sdkman.command instead");
this.command = major? Sdkman.Command.MAJOR: Sdkman.Command.MINOR;
}

Expand Down

0 comments on commit f1c73e2

Please sign in to comment.