You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "redzi (via GitHub)" <gi...@apache.org> on 2023/11/19 12:25:10 UTC

[PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

redzi opened a new pull request, #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67

   Following this checklist to help us incorporate your 
   contribution quickly and easily:
   
    - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MJAR) filed 
          for the change (usually before you start working on it).  Trivial changes like typos do not 
          require a JIRA issue.  Your pull request should address just this issue, without 
          pulling in other changes.
    - [x] Each commit in the pull request should have a meaningful subject line and body.
    - [x] Format the pull request title like `[MJAR-XXX] - Fixes bug in ApproximateQuantiles`,
          where you replace `MJAR-XXX` with the appropriate JIRA issue. Best practice
          is to use the JIRA issue title in the pull request title and in the first line of the 
          commit message.
    - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [x] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will 
          be performed on your pull request automatically.
    - [x] You have run the integration tests successfully (`mvn -Prun-its clean verify`).
   
   To make clear that you license your contribution under 
   the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [x] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   Underlining issue: [MJAR-296](https://issues.apache.org/jira/browse/MJAR-296).
   Goal:
   * allow to include in the resulting archive files that are excluded by default - e.g. .gitignore, etc.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "jira-importer (via GitHub)" <gi...@apache.org>.
jira-importer commented on PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#issuecomment-2956745692

   Resolve #441


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "redzi (via GitHub)" <gi...@apache.org>.
redzi commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1399786808


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -262,7 +294,7 @@ public File createArchive() throws MojoExecutionException {
                     getLog().warn("JAR will be empty - no content was marked for inclusion!");
                 }
             } else {
-                archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
+                archiver.getArchiver().addFileSet(getFileSet(contentDirectory));

Review Comment:
   `jarContentFileSet` is of type `org.apache.maven.shared.model.fileset.FileSet`, while `plexus-archiver` accepts `org.codehaus.plexus.archiver.FileSet`.
   
   Unfortunately there is no way of setting the `usingDefaultExcludes` flag in a flowable way so the method is a bit longer that it could have been.
   PS. `addDirectory` method of `org.codehaus.plexus.archiver.AbstractArchiver` has been deprecated in the latest version of  the archiver so moving away from it makes sense.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "jira-importer (via GitHub)" <gi...@apache.org>.
jira-importer commented on PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#issuecomment-2956776957

   Resolve #441


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#issuecomment-2043758679

   @redzi , @michael-o - fixed  and tested - should be ok


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1556394300


##########
src/it/MJAR-296/src/main/resources/.gitignore:
##########


Review Comment:
   `.gitignore` is not excluded by default: https://github.com/codehaus-plexus/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/AbstractScanner.java
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1557300514


##########
src/it/MJAR-296-exclude-default/setup.groovy:
##########
@@ -0,0 +1,29 @@
+import java.nio.file.Files
+import java.nio.file.Paths
+
+/*
+ * 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.
+ */
+
+// excluded files are not copied by m-invoker-p - so we need create one
+
+def resDir = basedir.toPath().resolve("src/main/resources")
+Files.createDirectories(resDir)
+Files.createFile(resDir.resolve(".cvsignore"))
+
+return true

Review Comment:
   My bad, let's leave as-is.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1550563632


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -262,7 +294,7 @@ public File createArchive() throws MojoExecutionException {
                     getLog().warn("JAR will be empty - no content was marked for inclusion!");
                 }
             } else {
-                archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
+                archiver.getArchiver().addFileSet(getFileSet(contentDirectory));

Review Comment:
   Maybe we can simple add next method `addDirectory` to Archiver with `addDefaultExcludes`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1557301724


##########
src/it/MJAR-296-exclude-default/pom.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>mjar-296-exclude-default</artifactId>
+  <name>mjar-296-suppress-default-excludes</name>
+  <description>Verifies that the resulting jar not includes files excluded by default</description>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.build.outputTimestamp>2023-11-19T13:25:58Z</project.build.outputTimestamp>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>@version.maven-resources-plugin@</version>
+          <configuration>
+            <addDefaultExcludes>false</addDefaultExcludes>

Review Comment:
   Totally right, thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1555085244


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -222,6 +253,7 @@ public File createArchive() throws MojoExecutionException {
         jarContentFileSet.setDirectory(getClassesDirectory().getAbsolutePath());
         jarContentFileSet.setIncludes(Arrays.asList(getIncludes()));
         jarContentFileSet.setExcludes(Arrays.asList(getExcludes()));
+        jarContentFileSet.setUseDefaultExcludes(addDefaultExcludes);

Review Comment:
   As `jarContentFileSet` is only used for searching for multi release and module descriptor I will not add this line at all



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
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
   
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "redzi (via GitHub)" <gi...@apache.org>.
redzi commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1399786808


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -262,7 +294,7 @@ public File createArchive() throws MojoExecutionException {
                     getLog().warn("JAR will be empty - no content was marked for inclusion!");
                 }
             } else {
-                archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
+                archiver.getArchiver().addFileSet(getFileSet(contentDirectory));

Review Comment:
   `jarContentFileSet` is of type `org.apache.maven.shared.model.fileset.FileSet`, while `plexus-archiver` accepts `org.codehaus.plexus.archiver.FileSet`.
   
   Unfortunately there is no way of setting the `usingDefaultExcludes` flag in a flowable way so the method is a bit longer that it could have been.
   PS. `addDirectory` method of `org.codehaus.plexus.archiver.Archiver` has been deprecated for a while so moving away from it makes sense.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1557063948


##########
src/it/MJAR-296-exclude-default/setup.groovy:
##########
@@ -0,0 +1,29 @@
+import java.nio.file.Files
+import java.nio.file.Paths
+
+/*
+ * 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.
+ */
+
+// excluded files are not copied by m-invoker-p - so we need create one
+
+def resDir = basedir.toPath().resolve("src/main/resources")
+Files.createDirectories(resDir)
+Files.createFile(resDir.resolve(".cvsignore"))
+
+return true

Review Comment:
   Why not simply add them to revision control instead of creating them?



##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -169,6 +170,38 @@ public abstract class AbstractJarMojo extends AbstractMojo {
     @Parameter(property = "maven.jar.detectMultiReleaseJar", defaultValue = "true")
     private boolean detectMultiReleaseJar;
 
+    /**
+     * If set to {@code false}, the files that by default are excluded from the resulting archive,

Review Comment:
   files and directories



##########
src/it/MJAR-296-exclude-default/pom.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>mjar-296-exclude-default</artifactId>
+  <name>mjar-296-suppress-default-excludes</name>
+  <description>Verifies that the resulting jar not includes files excluded by default</description>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.build.outputTimestamp>2023-11-19T13:25:58Z</project.build.outputTimestamp>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>@version.maven-resources-plugin@</version>
+          <configuration>
+            <addDefaultExcludes>false</addDefaultExcludes>

Review Comment:
   I wonder why this is `false`, but the `.cvsignore` is excluded`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1555085389


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -334,4 +366,13 @@ private String[] getExcludes() {
         }
         return DEFAULT_EXCLUDES;
     }
+
+    private org.codehaus.plexus.archiver.FileSet getFileSet(File contentDirectory) {
+        DefaultFileSet fileSet = DefaultFileSet.fileSet(contentDirectory)
+                .includeExclude(getIncludes(), getExcludes())
+                .includeEmptyDirs(true);
+
+        fileSet.setUsingDefaultExcludes(false);

Review Comment:
   This one should be set according to new parameter.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1557255168


##########
src/it/MJAR-296-exclude-default/setup.groovy:
##########
@@ -0,0 +1,29 @@
+import java.nio.file.Files
+import java.nio.file.Paths
+
+/*
+ * 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.
+ */
+
+// excluded files are not copied by m-invoker-p - so we need create one
+
+def resDir = basedir.toPath().resolve("src/main/resources")
+Files.createDirectories(resDir)
+Files.createFile(resDir.resolve(".cvsignore"))
+
+return true

Review Comment:
   m-invoke-p will skip default excludes files during copping ... so we need create one
   I can try with: https://maven.apache.org/plugins/maven-invoker-plugin/integration-test-mojo.html#cloneAllFiles



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "redzi (via GitHub)" <gi...@apache.org>.
redzi commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1405411663


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -262,7 +294,7 @@ public File createArchive() throws MojoExecutionException {
                     getLog().warn("JAR will be empty - no content was marked for inclusion!");
                 }
             } else {
-                archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
+                archiver.getArchiver().addFileSet(getFileSet(contentDirectory));

Review Comment:
   @michael-o any thoughts?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski merged PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1550560439


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -262,7 +294,7 @@ public File createArchive() throws MojoExecutionException {
                     getLog().warn("JAR will be empty - no content was marked for inclusion!");
                 }
             } else {
-                archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
+                archiver.getArchiver().addFileSet(getFileSet(contentDirectory));

Review Comment:
   Ok, it looks a more complicated `org.codehaus.plexus.archiver.FileSet` is only a configuration class which is used in plexus archiver .... 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1550413950


##########
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
+    }

Review Comment:
   We can simply use:
   
   ```
   assert  target.isDirectory()
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1556394734


##########
src/it/MJAR-296/pom.xml:
##########
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>mjar-296-suppress-default-excludes</artifactId>
+  <name>mjar-296-suppress-default-excludes</name>
+  <description>Verifies that the resulting jar includes files excluded by default</description>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.build.outputTimestamp>2023-11-19T13:25:58Z</project.build.outputTimestamp>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <addDefaultExcludes>false</addDefaultExcludes>

Review Comment:
   we also need a test with true value 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1550519016


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -262,7 +294,7 @@ public File createArchive() throws MojoExecutionException {
                     getLog().warn("JAR will be empty - no content was marked for inclusion!");
                 }
             } else {
-                archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
+                archiver.getArchiver().addFileSet(getFileSet(contentDirectory));

Review Comment:
   I would like to use only `org.codehaus.plexus.archiver.FileSet`, there is a method: `getIncludes` so we can drop a using of `rg.apache.maven.shared.model.fileset.FileSet` at all.
   Also dependency to `file-management` can be removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1558229755


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -169,6 +170,38 @@ public abstract class AbstractJarMojo extends AbstractMojo {
     @Parameter(property = "maven.jar.detectMultiReleaseJar", defaultValue = "true")
     private boolean detectMultiReleaseJar;
 
+    /**
+     * If set to {@code false}, the files that by default are excluded from the resulting archive,

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1557256798


##########
src/it/MJAR-296-exclude-default/pom.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>mjar-296-exclude-default</artifactId>
+  <name>mjar-296-suppress-default-excludes</name>
+  <description>Verifies that the resulting jar not includes files excluded by default</description>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.build.outputTimestamp>2023-11-19T13:25:58Z</project.build.outputTimestamp>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>@version.maven-resources-plugin@</version>
+          <configuration>
+            <addDefaultExcludes>false</addDefaultExcludes>

Review Comment:
   it is param for m-resource-p - all resources should be copied and finally should be filtered by m-jar-p



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1398478243


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -262,7 +294,7 @@ public File createArchive() throws MojoExecutionException {
                     getLog().warn("JAR will be empty - no content was marked for inclusion!");
                 }
             } else {
-                archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
+                archiver.getArchiver().addFileSet(getFileSet(contentDirectory));

Review Comment:
   Call me stupid, but isn't this exactly what `jarContentFileSet` is about? What am I missing here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MJAR-296] Allow including files excluded by default. [maven-jar-plugin]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #67:
URL: https://github.com/apache/maven-jar-plugin/pull/67#discussion_r1405415009


##########
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java:
##########
@@ -262,7 +294,7 @@ public File createArchive() throws MojoExecutionException {
                     getLog().warn("JAR will be empty - no content was marked for inclusion!");
                 }
             } else {
-                archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
+                archiver.getArchiver().addFileSet(getFileSet(contentDirectory));

Review Comment:
   I need to look at it, but have never applied any real fixes to this plugin. It won't happen before next month. Maybe someone with more knowledge can intervene. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org