Return-Path: X-Original-To: apmail-maven-issues-archive@minotaur.apache.org Delivered-To: apmail-maven-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A90A117DC7 for ; Thu, 3 Mar 2016 06:44:18 +0000 (UTC) Received: (qmail 5612 invoked by uid 500); 3 Mar 2016 06:44:18 -0000 Delivered-To: apmail-maven-issues-archive@maven.apache.org Received: (qmail 5562 invoked by uid 500); 3 Mar 2016 06:44:18 -0000 Mailing-List: contact issues-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list issues@maven.apache.org Received: (qmail 5551 invoked by uid 99); 3 Mar 2016 06:44:18 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2016 06:44:18 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 2DE2D2C1F6A for ; Thu, 3 Mar 2016 06:44:18 +0000 (UTC) Date: Thu, 3 Mar 2016 06:44:18 +0000 (UTC) From: "Plamen Totev (JIRA)" To: issues@maven.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (MSOURCES-95) When one of the source folders is empty the source jar is recreated even when sources not changed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MSOURCES-95?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Plamen Totev updated MSOURCES-95: --------------------------------- Attachment: reproduce-project.zip > When one of the source folders is empty the source jar is recreated even when sources not changed > ------------------------------------------------------------------------------------------------- > > Key: MSOURCES-95 > URL: https://issues.apache.org/jira/browse/MSOURCES-95 > Project: Maven Source Plugin > Issue Type: Bug > Reporter: Plamen Totev > Priority: Minor > Attachments: reproduce-project.zip > > > There is issue opened in Plexus Archive project - https://github.com/codehaus-plexus/plexus-archiver/issues/24 > In short if you download the attached zip and build it several times you'll see that the source jar is build every time no matter that the source are not changed. That's because {{target/generated-sources/annotations}} is empty. I think the reason for this behavior is that the default inclusion pattern in {{AbstractSourceJarMojo}} is {{\*\*/\*}}. If it's {{\*\*/\*\*}} then the jar will not be rebuilded. Is there any reason why it's {{\*\*/\*}} and not {{\*\*/\*\*}} ? > In the next paragraphs I'll try to explain why the second patter work and the first not. > Let's say we have the following directory: > {code} > + src > +--+ main > +--+ java > +--+ app > | +--+ App.java > | > +--+ empty_dir > {code} > when added to {{JarArchiver}} with prefix "" (empty string) this is how Plexus Archiver "sees" them: > {code} > src/main/java -> "" (empty string) > src/main/java/app -> "app" > src/main/java/app/App.java -> "app/App.java" > src/main/java/empty_dir -> "empty_dir" > {code} > To decide which entries to add Plexus Archives applies inclusion and exclusion patterns. Internally it uses {{org.codehaus.plexus.util.DirectoryScanner}} (https://github.com/codehaus-plexus/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/DirectoryScanner.java). The JavaDoc contains nice explanation how the patterns are applied but in the next paragraph I'll try to explain in short what happens. > When the pattern is set to {{\*\*/\*}} will match all but /src/main/java (("", "app", "app/App.java", "empty_dir")). This is because the pattern matches zero or more path segments, followed by any path segment. src/main/java is mapped to "" so the pattern will not match it (it's empty path segment followed by nothing). So far so good. But what if the source directory is empty(src/main/java). Then nothing will be matched and we'll end with empty resource collection to add to the archive. And because it's empty there is no way to know when it was last modified so Plexus Archiver will do the safe thing and recreate the archive. After all when the archive was created the pattern may have matched something and the archive is not empty so it's outdated. > What if the pattern is set to {{\*\*/\*\*}}. Then it matches zero or more path segments, followed by zero or more path segments - in other words everything (my understanding is that it's the same as {{\*\*}} - match everything). So if /src/main/java is empty we'll end up with collection containing only "" - file resource with empty name. Because of the empty name it won't be added to the archive(and that's exactly what we want) but there is at least one resource with last modification date so now Plexus Archiver knows if the archive is up to date or not. If there were files in the directory and now there in none then the directory mast modification date will be newer than the one of the archive. -- This message was sent by Atlassian JIRA (v6.3.4#6332)