• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jreleaser / jreleaser / #556

22 Nov 2025 04:17PM UTC coverage: 46.213% (-2.0%) from 48.203%
#556

push

github

aalmiray
feat(jdks): Allow filtering by platform

Closes #2000

Co-authored-by: Ixchel Ruiz <ixchelruiz@yahoo.com>

0 of 42 new or added lines in 5 files covered. (0.0%)

1116 existing lines in 107 files now uncovered.

24939 of 53965 relevant lines covered (46.21%)

0.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/plugins/jreleaser-maven-plugin/src/main/java/org/jreleaser/maven/plugin/JReleaserInitMojo.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 *
4
 * Copyright 2020-2025 The JReleaser authors.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     https://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
package org.jreleaser.maven.plugin;
19

20
import org.apache.maven.plugin.AbstractMojo;
21
import org.apache.maven.plugin.MojoExecutionException;
22
import org.apache.maven.plugin.MojoFailureException;
23
import org.apache.maven.plugins.annotations.Mojo;
24
import org.apache.maven.plugins.annotations.Parameter;
25
import org.apache.maven.project.MavenProject;
26
import org.jreleaser.engine.init.Init;
27
import org.jreleaser.logging.JReleaserLogger;
28
import org.jreleaser.maven.plugin.internal.JReleaserLoggerAdapter;
29
import org.jreleaser.model.JReleaserException;
30

31
import java.io.File;
32
import java.io.FileOutputStream;
33
import java.io.IOException;
34
import java.io.PrintWriter;
35

36
import static org.jreleaser.bundle.RB.$;
37
import static org.jreleaser.util.IoUtils.newPrintWriter;
38

39
/**
40
 * Create a jreleaser config file.
41
 *
42
 * @author Andres Almiray
43
 * @since 1.4.0
44
 */
45
@Mojo(threadSafe = true, name = "init")
UNCOV
46
public class JReleaserInitMojo extends AbstractMojo {
×
47
    /**
48
     * The Maven project.
49
     */
50
    @Parameter(defaultValue = "${project}", readonly = true, required = true)
51
    protected MavenProject project;
52
    @Parameter(property = "jreleaser.output.directory", defaultValue = "${project.basedir}")
53
    protected File outputDirectory;
54
    /**
55
     * Skip execution.
56
     */
57
    @Parameter(property = "jreleaser.init.skip")
58
    private boolean skip;
59
    /**
60
     * Configuration file format.
61
     */
62
    @Parameter(property = "jreleaser.init.format")
63
    private String format;
64
    /**
65
     * Overwrite existing files.
66
     */
67
    @Parameter(property = "jreleaser.init.overwrite")
68
    private boolean overwrite;
69

70
    @Override
71
    public void execute() throws MojoExecutionException, MojoFailureException {
UNCOV
72
        Banner.display(project, getLog());
×
UNCOV
73
        if (skip) {
×
74
            getLog().info("Execution has been explicitly skipped.");
×
75
            return;
×
76
        }
77

UNCOV
78
        if (null == outputDirectory) {
×
79
            outputDirectory = project.getBasedir();
×
80
        }
81

UNCOV
82
        JReleaserLogger logger = getLogger();
×
83
        try {
UNCOV
84
            Init.execute(logger, format, overwrite, outputDirectory.toPath());
×
85
        } catch (IllegalStateException e) {
×
86
            throw new JReleaserException($("ERROR_unexpected_error"), e);
×
87
        } finally {
UNCOV
88
            if (null != logger) logger.close();
×
89
        }
UNCOV
90
    }
×
91

92
    protected JReleaserLogger getLogger() throws MojoExecutionException {
UNCOV
93
        return new JReleaserLoggerAdapter(createTracer(), getLog());
×
94
    }
95

96
    protected PrintWriter createTracer() throws MojoExecutionException {
97
        try {
UNCOV
98
            java.nio.file.Files.createDirectories(outputDirectory.toPath());
×
UNCOV
99
            return newPrintWriter(new FileOutputStream(outputDirectory.toPath().resolve("trace.log").toFile()));
×
100
        } catch (IOException e) {
×
101
            throw new MojoExecutionException("Could not initialize trace file", e);
×
102
        }
103
    }
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc