From 7ab92934c00097e64c80ebb42dcaedd65ac214b3 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 2 Jul 2022 18:12:51 +0200 Subject: [PATCH] [MASSEMBLY-964] Fix initFile for FileLocation, UrlLocation method FileLocation.initFile was private and can not be override in child class --- src/it/projects/bugs/massembly-964/pom.xml | 66 +++++++++++++++++++ .../projects/bugs/massembly-964/verify.groovy | 23 +++++++ .../plugins/assembly/io/FileLocation.java | 16 ++--- .../plugins/assembly/io/URLLocation.java | 4 +- 4 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 src/it/projects/bugs/massembly-964/pom.xml create mode 100644 src/it/projects/bugs/massembly-964/verify.groovy diff --git a/src/it/projects/bugs/massembly-964/pom.xml b/src/it/projects/bugs/massembly-964/pom.xml new file mode 100644 index 000000000..4ba47b96b --- /dev/null +++ b/src/it/projects/bugs/massembly-964/pom.xml @@ -0,0 +1,66 @@ + + + + 4.0.0 + + org.apache.maven.plugins.assembly.it + massembly964 + 0.0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-assembly-plugin + @project.version@ + + + org.apache.apache.resources + apache-source-release-assembly-descriptor + 1.0.6 + + + + + source-release-assembly + package + + single + + + true + + source-release + + posix + + + + + + + diff --git a/src/it/projects/bugs/massembly-964/verify.groovy b/src/it/projects/bugs/massembly-964/verify.groovy new file mode 100644 index 000000000..561cf4b19 --- /dev/null +++ b/src/it/projects/bugs/massembly-964/verify.groovy @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +def sourceRelease = new File( basedir, "target/massembly964-0.0.1-SNAPSHOT-source-release.zip" ) + +assert sourceRelease.isFile() +assert sourceRelease.length() > 0 diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/FileLocation.java b/src/main/java/org/apache/maven/plugins/assembly/io/FileLocation.java index ee13dda9a..02e660473 100644 --- a/src/main/java/org/apache/maven/plugins/assembly/io/FileLocation.java +++ b/src/main/java/org/apache/maven/plugins/assembly/io/FileLocation.java @@ -58,7 +58,7 @@ class FileLocation this.specification = specification; } - /** {@inheritDoc} */ + @Override public void close() { if ( ( channel != null ) && channel.isOpen() ) @@ -86,7 +86,7 @@ public void close() } } - /** {@inheritDoc} */ + @Override public File getFile() throws IOException { @@ -107,7 +107,7 @@ File unsafeGetFile() * initialize file. * @throws IOException in case of error */ - private void initFile() + protected void initFile() throws IOException { if ( file == null ) @@ -129,13 +129,13 @@ protected void setFile( File file ) this.file = file; } - /** {@inheritDoc} */ + @Override public String getSpecification() { return specification; } - /** {@inheritDoc} */ + @Override public void open() throws IOException { @@ -148,7 +148,7 @@ public void open() } } - /** {@inheritDoc} */ + @Override public int read( ByteBuffer buffer ) throws IOException { @@ -156,7 +156,7 @@ public int read( ByteBuffer buffer ) return channel.read( buffer ); } - /** {@inheritDoc} */ + @Override public int read( byte[] buffer ) throws IOException { @@ -164,7 +164,7 @@ public int read( byte[] buffer ) return channel.read( ByteBuffer.wrap( buffer ) ); } - /** {@inheritDoc} */ + @Override public InputStream getInputStream() throws IOException { diff --git a/src/main/java/org/apache/maven/plugins/assembly/io/URLLocation.java b/src/main/java/org/apache/maven/plugins/assembly/io/URLLocation.java index bd7008f34..d745a20d3 100644 --- a/src/main/java/org/apache/maven/plugins/assembly/io/URLLocation.java +++ b/src/main/java/org/apache/maven/plugins/assembly/io/URLLocation.java @@ -59,8 +59,8 @@ class URLLocation this.tempFileDeleteOnExit = tempFileDeleteOnExit; } - /** {@inheritDoc} */ - void initFile() + @Override + protected void initFile() throws IOException { if ( unsafeGetFile() == null )