Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing @Override annotations #246

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ private SimpleFilter(
}

/** {@inheritDoc} */
@Override
public boolean canFilter(File jar) {
return jars.contains(jar);
}

/** {@inheritDoc} */
@Override
public boolean isFiltered(String classFile) {
String path = normalizePath(classFile);

Expand Down Expand Up @@ -155,5 +157,6 @@ private Set<String> normalizePatterns(Set<String> patterns) {
}

/** {@inheritDoc} */
@Override
public void finished() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ private boolean isExcluded(String path) {
return false;
}

@Override
public boolean canRelocatePath(String path) {
if (rawString) {
return Pattern.compile(pathPattern).matcher(path).find();
Expand All @@ -192,10 +193,12 @@ public boolean canRelocatePath(String path) {
return isIncluded(path) && !isExcluded(path) && path.startsWith(pathPattern);
}

@Override
public boolean canRelocateClass(String clazz) {
return !rawString && clazz.indexOf('/') < 0 && canRelocatePath(clazz.replace('.', '/'));
}

@Override
public String relocatePath(String path) {
if (rawString) {
return path.replaceAll(pathPattern, shadedPathPattern);
Expand All @@ -204,10 +207,12 @@ public String relocatePath(String path) {
}
}

@Override
public String relocateClass(String clazz) {
return rawString ? clazz : clazz.replaceFirst(pattern, shadedPattern);
}

@Override
public String applyToSourceContent(String sourceContent) {
if (rawString) {
return sourceContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* An abstract class to implement once the old non-reproducible ResourceTransformer API.
*/
abstract class AbstractCompatibilityTransformer implements ReproducibleResourceTransformer {
@Override
public final void processResource(String resource, InputStream is, List<Relocator> relocators) throws IOException {
processResource(resource, is, relocators, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,25 @@ public class ApacheLicenseResourceTransformer extends AbstractCompatibilityTrans

private static final String LICENSE_MD_PATH = "META-INF/LICENSE.md";

@Override
public boolean canTransformResource(String resource) {
return LICENSE_PATH.equalsIgnoreCase(resource)
|| LICENSE_TXT_PATH.regionMatches(true, 0, resource, 0, LICENSE_TXT_PATH.length())
|| LICENSE_MD_PATH.regionMatches(true, 0, resource, 0, LICENSE_MD_PATH.length());
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
// no op
}

@Override
public boolean hasTransformedResource() {
return false;
}

@Override
public void modifyOutputStream(JarOutputStream os) throws IOException {
// no op
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ public class ApacheNoticeResourceTransformer extends AbstractCompatibilityTransf

private static final String NOTICE_MD_PATH = "META-INF/NOTICE.md";

@Override
public boolean canTransformResource(String resource) {
return NOTICE_PATH.equalsIgnoreCase(resource)
|| NOTICE_TXT_PATH.equalsIgnoreCase(resource)
|| NOTICE_MD_PATH.equalsIgnoreCase(resource);
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
if (entries.isEmpty()) {
Expand Down Expand Up @@ -167,10 +169,12 @@ public void processResource(String resource, InputStream is, List<Relocator> rel
}
}

@Override
public boolean hasTransformedResource() {
return true;
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
JarEntry jarEntry = new JarEntry(NOTICE_PATH);
jarEntry.setTime(time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ public class AppendingTransformer extends AbstractCompatibilityTransformer {

private long time = Long.MIN_VALUE;

@Override
public boolean canTransformResource(String r) {
return resource != null && resource.equalsIgnoreCase(r);
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
IOUtil.copy(is, data);
Expand All @@ -51,10 +53,12 @@ public void processResource(String resource, InputStream is, List<Relocator> rel
}
}

@Override
public boolean hasTransformedResource() {
return data.size() > 0;
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
JarEntry jarEntry = new JarEntry(resource);
jarEntry.setTime(time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@ public class ComponentsXmlResourceTransformer extends AbstractCompatibilityTrans

public static final String COMPONENTS_XML_PATH = "META-INF/plexus/components.xml";

@Override
public boolean canTransformResource(String resource) {
return COMPONENTS_XML_PATH.equals(resource);
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
Xpp3Dom newDom;

try {
BufferedInputStream bis = new BufferedInputStream(is) {
@Override
public void close() throws IOException {
// leave ZIP open
}
Expand Down Expand Up @@ -117,6 +120,7 @@ public void close() throws IOException {
}
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
JarEntry jarEntry = new JarEntry(COMPONENTS_XML_PATH);
jarEntry.setTime(time);
Expand All @@ -130,6 +134,7 @@ public void modifyOutputStream(JarOutputStream jos) throws IOException {
components.clear();
}

@Override
public boolean hasTransformedResource() {
return !components.isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class DontIncludeResourceTransformer extends AbstractCompatibilityTransfo

List<String> resources;

@Override
public boolean canTransformResource(String r) {
if ((resource != null && !resource.isEmpty()) && r.endsWith(resource)) {
return true;
Expand All @@ -50,15 +51,18 @@ public boolean canTransformResource(String r) {
return false;
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
// no op
}

@Override
public boolean hasTransformedResource() {
return false;
}

@Override
public void modifyOutputStream(JarOutputStream os) throws IOException {
// no op
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,25 @@ public class IncludeResourceTransformer extends AbstractCompatibilityTransformer

private long time = Long.MIN_VALUE;

@Override
public boolean canTransformResource(String r) {
return false;
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
if (time > this.time) {
this.time = time;
}
}

@Override
public boolean hasTransformedResource() {
return file != null && file.exists();
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
JarEntry jarEntry = new JarEntry(resource);
jarEntry.setTime(time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@ public class PluginXmlResourceTransformer extends AbstractCompatibilityTransform

public static final String PLUGIN_XML_PATH = "META-INF/maven/plugin.xml";

@Override
public boolean canTransformResource(String resource) {
return PLUGIN_XML_PATH.equals(resource);
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
Xpp3Dom newDom;

try {
BufferedInputStream bis = new BufferedInputStream(is) {
@Override
public void close() throws IOException {
// leave ZIP open
}
Expand Down Expand Up @@ -116,6 +119,7 @@ public void close() throws IOException {
}
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
byte[] data = getTransformedResource();

Expand All @@ -128,6 +132,7 @@ public void modifyOutputStream(JarOutputStream jos) throws IOException {
mojos.clear();
}

@Override
public boolean hasTransformedResource() {
return !mojos.isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public void setBasename(String basename) {
resourceBundlePattern = Pattern.compile(basename + "(_[a-zA-Z]+){0,3}\\.properties");
}

@Override
public boolean canTransformResource(String r) {
return resourceBundlePattern != null && resourceBundlePattern.matcher(r).matches();
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
ByteArrayOutputStream data = dataMap.get(resource);
Expand All @@ -72,10 +74,12 @@ public void processResource(String resource, InputStream is, List<Relocator> rel
}
}

@Override
public boolean hasTransformedResource() {
return !dataMap.isEmpty();
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
for (Map.Entry<String, ByteArrayOutputStream> dataEntry : dataMap.entrySet()) {
JarEntry jarEntry = new JarEntry(dataEntry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public class ServicesResourceTransformer extends AbstractCompatibilityTransforme

private long time = Long.MIN_VALUE;

@Override
public boolean canTransformResource(String resource) {
return resource.startsWith(SERVICES_PATH);
}

@Override
public void processResource(String resource, InputStream is, final List<Relocator> relocators, long time)
throws IOException {
resource = resource.substring(SERVICES_PATH.length() + 1);
Expand Down Expand Up @@ -80,10 +82,12 @@ public void processResource(String resource, InputStream is, final List<Relocato
}
}

@Override
public boolean hasTransformedResource() {
return !serviceEntries.isEmpty();
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
for (Map.Entry<String, Set<String>> entry : serviceEntries.entrySet()) {
String key = entry.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ public class XmlAppendingTransformer extends AbstractCompatibilityTransformer {

private long time = Long.MIN_VALUE;

@Override
public boolean canTransformResource(String r) {
return resource != null && resource.equalsIgnoreCase(r);
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
Document r;
Expand All @@ -65,6 +67,7 @@ public void processResource(String resource, InputStream is, List<Relocator> rel
builder.setExpandEntities(false);
if (ignoreDtd) {
builder.setEntityResolver(new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
return new InputSource(new StringReader(""));
Expand Down Expand Up @@ -105,10 +108,12 @@ public InputSource resolveEntity(String publicId, String systemId)
}
}

@Override
public boolean hasTransformedResource() {
return doc != null;
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
JarEntry jarEntry = new JarEntry(resource);
jarEntry.setTime(time);
Expand Down
Loading