[
https://issues.apache.org/jira/browse/MJAR-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833736#comment-17833736
]
ASF GitHub Bot commented on MJAR-296:
-------------------------------------
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1550416370
##########
src/it/MJAR-296/verify.groovy:
##########
@@ -0,0 +1,58 @@
+
+/*
+ * 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.
+ */
+
+import java.util.jar.*;
+
+boolean result = false;
+
+try
+{
+ File target = new File( basedir, "target" )
+ if ( !target.exists() || !target.isDirectory() ) {
+ System.err.println( "target file is missing or not a directory." )
+ return result
+ }
+
+ File artifact = new File( target,
"mjar-296-suppress-default-excludes-1.0-SNAPSHOT.jar" )
+ if ( !artifact.exists() || artifact.isDirectory() ) {
+ System.err.println( "artifact file is missing or a directory." )
+ return result
+ }
+
+ String expectedFileName = ".gitignore"
+
+ JarFile jar = new JarFile( artifact )
+ Enumeration jarEntries = jar.entries()
+ while ( jarEntries.hasMoreElements() ) {
+ JarEntry entry = (JarEntry) jarEntries.nextElement();
+ if ( !entry.isDirectory() && expectedFileName.equals(entry.getName())
) {
+ result = true
+ }
+ }
Review Comment:
can be:
```
assert jar.getEntry('.gitignore') != null
```
> No way to suppress default excludes in maven-jar-plugin
> -------------------------------------------------------
>
> Key: MJAR-296
> URL: https://issues.apache.org/jira/browse/MJAR-296
> Project: Maven JAR Plugin
> Issue Type: Improvement
> Affects Versions: 3.3.0
> Reporter: G.Vaysman
> Priority: Major
> Attachments: jar-default-excludes.zip
>
>
> With the default excludes being expanded further (see
> org.codehaus.plexus.util.AbstractScanner.{*}_DEFAULTEXCLUDES_{*}), a resource
> directory **/ChangeSet/** will never be included in the JAR artifact.
> Some plugins (maven-resources-plugin, maven-assembly-plugin) already allow
> suppressing the exclusion, but not the maven-jar-plugin. Code analysis of the
> JarMojo -> DirectoryScanner call path confirms that there is no way to affect
> the FileSet configuration.
> Again, with ever expanding list of *_DEFAULTEXCLUDES,_* this, on our opinion,
> is quite detrimental, and due to backward compatibility, changing
> resource/package path (say, to ChangeSet2) is not an option.
> I am attaching a very simple project that shows two things:
> # The jar plugin skips adding the **/ChangeSet/** files
> # The resources plugin is configured not to skip (addDefaultExcludes) and
> behaves properly
--
This message was sent by Atlassian Jira
(v8.20.10#820010)