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

hazendaz / htmlcompressor-maven-plugin / 75

20 Apr 2025 06:38PM UTC coverage: 36.479% (+0.2%) from 36.249%
75

push

github

hazendaz
Change %s injector to be quoted "%s" instead

the underlying code with %s is invalid javascript.  By doing it this way, its now compliant.  The result is the same.  This is a breaking change for those using this.

44 of 218 branches covered (20.18%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

133 existing lines in 5 files now uncovered.

273 of 651 relevant lines covered (41.94%)

0.42 hits per line

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

69.05
/src/main/java/com/tunyk/mvn/plugins/htmlcompressor/XmlCompressor.java
1
/*
2
 * Copyright (c) 2011-2025 Alex Tunyk <alex at tunyk.com>.
3
 * Copyright (c) 2011-2025 Hazendaz <github.com/hazendaz>.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *   https://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 * See the NOTICE file distributed with this work for additional information
18
 * regarding copyright ownership.
19
 */
20
package com.tunyk.mvn.plugins.htmlcompressor;
21

22
import java.nio.charset.Charset;
23
import java.util.Map.Entry;
24
import java.util.concurrent.ConcurrentMap;
25

26
/**
27
 * The Class XmlCompressor.
28
 */
29
public class XmlCompressor {
30

31
    /** The Constant FILE_EXT. */
32
    private static final String[] FILE_EXT = { "xml" };
1✔
33

34
    /** The file ext. */
35
    private String[] fileExtensions;
36

37
    /** The src dir path. */
38
    private String srcDirPath;
39

40
    /** The target dir path. */
41
    private String targetDirPath;
42

43
    /** The file encoding. */
44
    private Charset fileEncoding;
45

46
    /** The xml compressor. */
47
    private com.googlecode.htmlcompressor.compressor.XmlCompressor xmlCompressor;
48

49
    /**
50
     * Instantiates a new xml compressor.
51
     *
52
     * @param srcDirPath
53
     *            the src dir path
54
     * @param targetDirPath
55
     *            the target dir path
56
     */
57
    public XmlCompressor(String srcDirPath, String targetDirPath) {
1✔
58
        this.srcDirPath = srcDirPath;
1✔
59
        this.targetDirPath = targetDirPath;
1✔
60
    }
1✔
61

62
    /**
63
     * Compress.
64
     *
65
     * @throws Exception
66
     *             the exception
67
     */
68
    public void compress() throws Exception {
69
        if (fileExtensions == null || fileExtensions.length == 0) {
1!
70
            fileExtensions = FILE_EXT;
1✔
71
        }
72

73
        FileTool fileTool = new FileTool(srcDirPath, fileExtensions, true);
1✔
74
        fileTool.setFileEncoding(fileEncoding);
1✔
75
        ConcurrentMap<String, String> map = fileTool.getFiles();
1✔
76

77
        if (xmlCompressor == null) {
1✔
78
            xmlCompressor = new com.googlecode.htmlcompressor.compressor.XmlCompressor();
1✔
79
        }
80

81
        for (Entry<String, String> key : map.entrySet()) {
1✔
82
            map.put(key.getKey(), xmlCompressor.compress(key.getValue()));
1✔
83
        }
1✔
84

85
        fileTool.writeFiles(map, targetDirPath);
1✔
86
    }
1✔
87

88
    /**
89
     * Gets the file extension.
90
     *
91
     * @return the file extensions
92
     */
93
    public String[] getFileExtensions() {
UNCOV
94
        return fileExtensions;
×
95
    }
96

97
    /**
98
     * Sets the file ext.
99
     *
100
     * @param fileExtensions
101
     *            the new file extensions
102
     */
103
    public void setFileExtensions(String[] fileExtensions) {
104
        this.fileExtensions = fileExtensions;
1✔
105
    }
1✔
106

107
    /**
108
     * Gets the src dir path.
109
     *
110
     * @return the src dir path
111
     */
112
    public String getSrcDirPath() {
UNCOV
113
        return srcDirPath;
×
114
    }
115

116
    /**
117
     * Sets the src dir path.
118
     *
119
     * @param srcDirPath
120
     *            the new src dir path
121
     */
122
    public void setSrcDirPath(String srcDirPath) {
123
        this.srcDirPath = srcDirPath;
×
UNCOV
124
    }
×
125

126
    /**
127
     * Gets the target dir path.
128
     *
129
     * @return the target dir path
130
     */
131
    public String getTargetDirPath() {
UNCOV
132
        return targetDirPath;
×
133
    }
134

135
    /**
136
     * Sets the target dir path.
137
     *
138
     * @param targetDirPath
139
     *            the new target dir path
140
     */
141
    public void setTargetDirPath(String targetDirPath) {
142
        this.targetDirPath = targetDirPath;
×
UNCOV
143
    }
×
144

145
    /**
146
     * Gets the file encoding.
147
     *
148
     * @return the file encoding
149
     */
150
    public Charset getFileEncoding() {
UNCOV
151
        return fileEncoding;
×
152
    }
153

154
    /**
155
     * Sets the file encoding.
156
     *
157
     * @param fileEncoding
158
     *            the new file encoding
159
     */
160
    public void setFileEncoding(Charset fileEncoding) {
161
        this.fileEncoding = fileEncoding == null ? Charset.defaultCharset() : fileEncoding;
1!
162
    }
1✔
163

164
    /**
165
     * Gets the xml compressor.
166
     *
167
     * @return the xml compressor
168
     */
169
    public com.googlecode.htmlcompressor.compressor.XmlCompressor getXmlCompressor() {
UNCOV
170
        return xmlCompressor;
×
171
    }
172

173
    /**
174
     * Sets the xml compressor.
175
     *
176
     * @param xmlCompressor
177
     *            the new xml compressor
178
     */
179
    public void setXmlCompressor(com.googlecode.htmlcompressor.compressor.XmlCompressor xmlCompressor) {
180
        this.xmlCompressor = xmlCompressor;
1✔
181
    }
1✔
182
}
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