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

jreleaser / jreleaser / #550

01 Nov 2025 03:54PM UTC coverage: 47.949% (-0.3%) from 48.255%
#550

push

github

aalmiray
build: Update jdks to Java 25

25852 of 53916 relevant lines covered (47.95%)

0.48 hits per line

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

0.0
/plugins/jreleaser-ant-tasks/src/main/java/org/jreleaser/ant/tasks/JReleaserInitTask.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.ant.tasks;
19

20
import org.apache.tools.ant.BuildException;
21
import org.apache.tools.ant.Task;
22
import org.jreleaser.ant.tasks.internal.JReleaserLoggerAdapter;
23
import org.jreleaser.engine.init.Init;
24
import org.jreleaser.logging.JReleaserLogger;
25
import org.jreleaser.model.JReleaserException;
26

27
import java.io.FileOutputStream;
28
import java.io.IOException;
29
import java.io.PrintWriter;
30
import java.nio.file.Files;
31
import java.nio.file.Path;
32

33
import static org.jreleaser.bundle.RB.$;
34
import static org.jreleaser.util.IoUtils.newPrintWriter;
35

36
/**
37
 * @author Andres Almiray
38
 * @since 0.1.0
39
 */
40
public class JReleaserInitTask extends Task {
×
41
    private boolean overwrite;
42
    private String format;
43
    private JReleaserLogger logger;
44

45
    public void setOverwrite(boolean overwrite) {
46
        this.overwrite = overwrite;
×
47
    }
×
48

49
    public void setFormat(String format) {
50
        this.format = format;
×
51
    }
×
52

53
    @Override
54
    public void execute() throws BuildException {
55
        Banner.display(newPrintWriter(System.err));
×
56
        try {
57
            initLogger();
×
58
            Init.execute(logger, format, overwrite, getOutputDirectory());
×
59
        } catch (IllegalStateException e) {
×
60
            throw new JReleaserException($("ERROR_unexpected_error"), e);
×
61
        } finally {
62
            if (null != logger) logger.close();
×
63
        }
64
    }
×
65

66
    private PrintWriter createTracer() {
67
        try {
68
            Path outputDirectory = getOutputDirectory()
×
69
                .resolve("out")
×
70
                .resolve("jreleaser");
×
71
            Files.createDirectories(outputDirectory);
×
72
            return newPrintWriter(new FileOutputStream(
×
73
                outputDirectory.resolve("trace.log").toFile()));
×
74
        } catch (IOException e) {
×
75
            throw new IllegalStateException("Could not initialize trace file", e);
×
76
        }
77
    }
78

79
    private Path getOutputDirectory() {
80
        return getProject().getBaseDir().toPath().normalize();
×
81
    }
82

83
    private void initLogger() {
84
        if (null == logger) {
×
85
            logger = new JReleaserLoggerAdapter(createTracer(), getProject());
×
86
        }
87
    }
×
88
}
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