You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/07/04 14:05:20 UTC

[maven-file-management] branch shared created (now fe1c33d)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a change to branch shared
in repository https://gitbox.apache.org/repos/asf/maven-file-management.git.


      at fe1c33d  remove dependency on maven-shared-io

This branch includes the following new commits:

     new 0ec5255  add .checkstyle to .gitignore
     new 6f4346f  Merge branch 'master' of github.com:apache/maven-file-management
     new fe1c33d  remove dependency on maven-shared-io

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-file-management] 03/03: remove dependency on maven-shared-io

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch shared
in repository https://gitbox.apache.org/repos/asf/maven-file-management.git

commit fe1c33d87109e060a5655861189632913069f138
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sat Jul 4 10:05:03 2020 -0400

    remove dependency on maven-shared-io
---
 pom.xml                                            |   5 -
 .../shared/model/fileset/util/FileSetManager.java  |  21 +-
 .../shared/model/fileset/util/MessageHolder.java   | 236 +++++++++++++++++++++
 .../shared/model/fileset/util/MessageLevels.java   |  99 +++++++++
 .../shared/model/fileset/util/MessageSink.java     |  35 +++
 .../shared/model/fileset/util/MojoLogSink.java     |  60 ++++++
 .../model/fileset/util/PlexusLoggerSink.java       |  63 ++++++
 7 files changed, 501 insertions(+), 18 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5abeb80..419d662 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,11 +72,6 @@
       <artifactId>maven-plugin-api</artifactId>
       <version>${mavenVersion}</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.maven.shared</groupId>
-      <artifactId>maven-shared-io</artifactId>
-      <version>3.0.0</version>
-    </dependency>
 
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
diff --git a/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java b/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java
index 3631e7f..311dcf9 100644
--- a/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java
+++ b/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java
@@ -33,11 +33,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.shared.io.logging.DefaultMessageHolder;
-import org.apache.maven.shared.io.logging.MessageHolder;
-import org.apache.maven.shared.io.logging.MessageLevels;
-import org.apache.maven.shared.io.logging.MojoLogSink;
-import org.apache.maven.shared.io.logging.PlexusLoggerSink;
 import org.apache.maven.shared.model.fileset.FileSet;
 import org.apache.maven.shared.model.fileset.mappers.FileNameMapper;
 import org.apache.maven.shared.model.fileset.mappers.MapperException;
@@ -68,20 +63,20 @@ public class FileSetManager
     /**
      * Create a new manager instance with the supplied log instance and flag for whether to output verbose messages.
      *
-     * @param log The mojo log instance
-     * @param verbose Whether to output verbose messages
+     * @param log the mojo log instance
+     * @param verbose whether to output verbose messages
      */
     public FileSetManager( Log log, boolean verbose )
     {
         if ( verbose )
         {
             this.messages =
-                new DefaultMessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) );
+                new MessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) );
         }
         else
         {
             this.messages =
-                new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) );
+                new MessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) );
         }
 
         this.verbose = verbose;
@@ -95,7 +90,7 @@ public class FileSetManager
     public FileSetManager( Log log )
     {
         this.messages =
-            new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) );
+            new MessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new MojoLogSink( log ) );
         this.verbose = false;
     }
 
@@ -109,12 +104,12 @@ public class FileSetManager
     {
         if ( verbose )
         {
-            this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO,
+            this.messages = new MessageHolder( MessageLevels.LEVEL_DEBUG, MessageLevels.LEVEL_INFO,
                                                       new PlexusLoggerSink( log ) );
         }
         else
         {
-            this.messages = new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO,
+            this.messages = new MessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO,
                                                       new PlexusLoggerSink( log ) );
         }
 
@@ -129,7 +124,7 @@ public class FileSetManager
     public FileSetManager( Logger log )
     {
         this.messages =
-            new DefaultMessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new PlexusLoggerSink( log ) );
+            new MessageHolder( MessageLevels.LEVEL_INFO, MessageLevels.LEVEL_INFO, new PlexusLoggerSink( log ) );
         this.verbose = false;
     }
 
diff --git a/src/main/java/org/apache/maven/shared/model/fileset/util/MessageHolder.java b/src/main/java/org/apache/maven/shared/model/fileset/util/MessageHolder.java
new file mode 100644
index 0000000..81f4814
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/model/fileset/util/MessageHolder.java
@@ -0,0 +1,236 @@
+package org.apache.maven.shared.model.fileset.util;
+
+/*
+ * 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.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+class MessageHolder
+{
+
+    private List<Message> messages = new ArrayList<Message>();
+
+    private Message currentMessage;
+
+    private int defaultMessageLevel = MessageLevels.LEVEL_INFO;
+
+    private boolean[] messageLevelStates;
+
+    private MessageSink onDemandSink;
+
+    MessageHolder( int maxMessageLevel, int defaultMessageLevel, MessageSink onDemandSink )
+    {
+        this.defaultMessageLevel = defaultMessageLevel;
+        this.onDemandSink = onDemandSink;
+        this.messageLevelStates = MessageLevels.getLevelStates( maxMessageLevel );
+    }
+
+    private MessageHolder addMessage( int level, CharSequence messagePart )
+    {
+        newMessage( level );
+        append( messagePart.toString() );
+
+        return this;
+    }
+
+    private MessageHolder addMessage( int level, Throwable error )
+    {
+        newMessage( level );
+        append( error );
+
+        return this;
+    }
+
+    private MessageHolder append( CharSequence messagePart )
+    {
+        if ( currentMessage == null )
+        {
+            newMessage();
+        }
+
+        currentMessage.append( messagePart.toString() );
+
+        return this;
+    }
+
+    private MessageHolder append( Throwable error )
+    {
+        if ( currentMessage == null )
+        {
+            newMessage();
+        }
+
+        currentMessage.setError( error );
+
+        return this;
+    }
+
+    MessageHolder newMessage()
+    {
+        newMessage( defaultMessageLevel );
+
+        return this;
+    }
+
+    private void newMessage( int messageLevel )
+    {
+        if ( onDemandSink != null && currentMessage != null )
+        {
+            renderTo( currentMessage, onDemandSink );
+        }
+
+        currentMessage = new Message( messageLevel, onDemandSink );
+        messages.add( currentMessage );
+    }
+
+    private static final class Message
+    {
+        private StringBuffer message = new StringBuffer();
+
+        private Throwable error;
+
+        private final int messageLevel;
+
+        private final MessageSink onDemandSink;
+
+        Message( int messageLevel, MessageSink onDemandSink )
+        {
+            this.messageLevel = messageLevel;
+
+            this.onDemandSink = onDemandSink;
+        }
+
+        Message setError( Throwable pError )
+        {
+            this.error = pError;
+            return this;
+        }
+
+        Message append( CharSequence pMessage )
+        {
+            this.message.append( pMessage.toString() );
+            return this;
+        }
+
+        private int getMessageLevel()
+        {
+            return messageLevel;
+        }
+
+        private CharSequence render()
+        {
+            StringBuffer buffer = new StringBuffer();
+
+            if ( onDemandSink == null )
+            {
+                buffer.append( '[' ).append( MessageLevels.getLevelLabel( messageLevel ) ).append( "] " );
+            }
+            if ( message != null && message.length() > 0 )
+            {
+                buffer.append( message );
+
+                if ( error != null )
+                {
+                    buffer.append( '\n' );
+                }
+            }
+
+            if ( error != null )
+            {
+                buffer.append( "Error:\n" );
+
+                StringWriter sw = new StringWriter();
+                PrintWriter pw = new PrintWriter( sw );
+                error.printStackTrace( pw );
+
+                buffer.append( sw.toString() );
+            }
+
+            return buffer;
+        }
+    }
+
+    MessageHolder addDebugMessage( CharSequence messagePart )
+    {
+        return addMessage( MessageLevels.LEVEL_DEBUG, messagePart );
+    }
+
+    MessageHolder addInfoMessage( CharSequence messagePart )
+    {
+        return addMessage( MessageLevels.LEVEL_INFO, messagePart );
+    }
+
+    MessageHolder addWarningMessage( Throwable error )
+    {
+        return addMessage( MessageLevels.LEVEL_WARNING, error );
+    }
+
+    MessageHolder addWarningMessage( CharSequence messagePart )
+    {
+        return addMessage( MessageLevels.LEVEL_WARNING, messagePart );
+    }
+
+    boolean isDebugEnabled()
+    {
+        return messageLevelStates[MessageLevels.LEVEL_DEBUG];
+    }
+
+    boolean isWarningEnabled()
+    {
+        return messageLevelStates[MessageLevels.LEVEL_WARNING];
+    }
+
+    void flush()
+    {
+        if ( onDemandSink != null && currentMessage != null )
+        {
+            renderTo( currentMessage, onDemandSink );
+            currentMessage = null;
+        }
+    }
+
+    private void renderTo( Message message, MessageSink sink )
+    {
+        switch ( message.getMessageLevel() )
+        {
+            case ( MessageLevels.LEVEL_SEVERE ):
+                sink.severe( message.render().toString() );
+                break;
+
+            case ( MessageLevels.LEVEL_ERROR ):
+                sink.error( message.render().toString() );
+                break;
+
+            case ( MessageLevels.LEVEL_WARNING ):
+                sink.warning( message.render().toString() );
+                break;
+
+            case ( MessageLevels.LEVEL_INFO ):
+                sink.info( message.render().toString() );
+                break;
+
+            default:
+                sink.debug( message.render().toString() );
+        }
+    }
+
+}
diff --git a/src/main/java/org/apache/maven/shared/model/fileset/util/MessageLevels.java b/src/main/java/org/apache/maven/shared/model/fileset/util/MessageLevels.java
new file mode 100644
index 0000000..fcf35aa
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/model/fileset/util/MessageLevels.java
@@ -0,0 +1,99 @@
+package org.apache.maven.shared.model.fileset.util;
+
+/*
+ * 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.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 
+ */
+final class MessageLevels
+{
+
+    static final int LEVEL_DEBUG = 0;
+    static final int LEVEL_INFO = 1;
+    static final int LEVEL_WARNING = 2;
+    static final int LEVEL_ERROR = 3;
+    static final int LEVEL_SEVERE = 4;
+    static final int LEVEL_DISABLED = 5;
+
+    private static final List<String> LEVEL_NAMES;
+
+    static
+    {
+        List<String> names = new ArrayList<String>();
+        names.add( "DEBUG" );
+        names.add( "INFO" );
+        names.add( "WARN" );
+        names.add( "ERROR" );
+        names.add( "SEVERE" );
+
+        LEVEL_NAMES = Collections.unmodifiableList( names );
+    }
+
+    private MessageLevels()
+    {
+    }
+
+    /**
+     * @param maxMessageLevel for which level
+     * @return level states
+     */
+    static boolean[] getLevelStates( int maxMessageLevel )
+    {
+        boolean[] states = new boolean[5];
+
+        Arrays.fill( states, false );
+
+        switch ( maxMessageLevel )
+        {
+            case ( LEVEL_DEBUG ):
+                states[LEVEL_DEBUG] = true;
+            case ( LEVEL_INFO ):
+                states[LEVEL_INFO] = true;
+            case ( LEVEL_WARNING ):
+                states[LEVEL_WARNING] = true;
+            case ( LEVEL_ERROR ):
+                states[LEVEL_ERROR] = true;
+            case ( LEVEL_SEVERE ):
+                states[LEVEL_SEVERE] = true;
+            default:
+        }
+
+        return states;
+    }
+
+    /**
+     * @param messageLevel the message level
+     * @return the label
+     */
+    static String getLevelLabel( int messageLevel )
+    {
+        if ( messageLevel > -1 && LEVEL_NAMES.size() > messageLevel )
+        {
+            return (String) LEVEL_NAMES.get( messageLevel );
+        }
+
+        throw new IllegalArgumentException( "Invalid message level: " + messageLevel );
+    }
+}
diff --git a/src/main/java/org/apache/maven/shared/model/fileset/util/MessageSink.java b/src/main/java/org/apache/maven/shared/model/fileset/util/MessageSink.java
new file mode 100644
index 0000000..843931a
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/model/fileset/util/MessageSink.java
@@ -0,0 +1,35 @@
+package org.apache.maven.shared.model.fileset.util;
+
+/*
+ * 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.
+ */
+
+interface MessageSink
+{
+
+    void debug( String message );
+
+    void info( String message );
+
+    void warning( String message );
+
+    void error( String message );
+
+    void severe( String message );
+
+}
diff --git a/src/main/java/org/apache/maven/shared/model/fileset/util/MojoLogSink.java b/src/main/java/org/apache/maven/shared/model/fileset/util/MojoLogSink.java
new file mode 100644
index 0000000..71fea4a
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/model/fileset/util/MojoLogSink.java
@@ -0,0 +1,60 @@
+package org.apache.maven.shared.model.fileset.util;
+
+/*
+ * 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 org.apache.maven.plugin.logging.Log;
+
+class MojoLogSink
+    implements MessageSink
+{
+
+    private final Log logger;
+
+    MojoLogSink( Log logger )
+    {
+        this.logger = logger;
+    }
+
+    public void debug( String message )
+    {
+        logger.debug( message );
+    }
+
+    public void error( String message )
+    {
+        logger.error( message );
+    }
+
+    public void info( String message )
+    {
+        logger.info( message );
+    }
+
+    public void severe( String message )
+    {
+        logger.error( message );
+    }
+
+    public void warning( String message )
+    {
+        logger.warn( message );
+    }
+
+}
diff --git a/src/main/java/org/apache/maven/shared/model/fileset/util/PlexusLoggerSink.java b/src/main/java/org/apache/maven/shared/model/fileset/util/PlexusLoggerSink.java
new file mode 100644
index 0000000..88e3d6f
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/model/fileset/util/PlexusLoggerSink.java
@@ -0,0 +1,63 @@
+package org.apache.maven.shared.model.fileset.util;
+
+/*
+ * 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 org.codehaus.plexus.logging.Logger;
+
+/**
+ * The plexus logger sink implementation.
+ */
+class PlexusLoggerSink
+    implements MessageSink
+{
+
+    private final Logger logger;
+
+    PlexusLoggerSink( Logger logger )
+    {
+        this.logger = logger;
+    }
+
+    public void debug( String message )
+    {
+        logger.debug( message );
+    }
+
+    public void error( String message )
+    {
+        logger.error( message );
+    }
+
+    public void info( String message )
+    {
+        logger.info( message );
+    }
+
+    public void severe( String message )
+    {
+        logger.fatalError( message );
+    }
+
+    public void warning( String message )
+    {
+        logger.warn( message );
+    }
+
+}


[maven-file-management] 01/03: add .checkstyle to .gitignore

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch shared
in repository https://gitbox.apache.org/repos/asf/maven-file-management.git

commit 0ec52554f4c958c4c6593d53bc41efaa973faee1
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sat Jul 4 09:33:22 2020 -0400

    add .checkstyle to .gitignore
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index f79c928..7495d7e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ out/
 /bootstrap
 /dependencies.xml
 .java-version
+.checkstyle


[maven-file-management] 02/03: Merge branch 'master' of github.com:apache/maven-file-management

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch shared
in repository https://gitbox.apache.org/repos/asf/maven-file-management.git

commit 6f4346fc91dc8f3e71ad273cae3683011377f204
Merge: 0ec5255 7f93b1d
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sat Jul 4 09:33:54 2020 -0400

    Merge branch 'master' of github.com:apache/maven-file-management

 .gitignore | 1 +
 pom.xml    | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)