Skip to content
Commits on Source (11)
target/
.project
.classpath
.settings/
.svn/
bin/
# Intellij
*.ipr
*.iml
.idea
out/
.DS_Store
/bootstrap
/dependencies.xml
.java-version
/**
* 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.
*/
asfMavenTlpStdBuild()
maven-shared-utils (3.2.1-1) unstable; urgency=medium
* Team upload.
* New upstream release
- Restored the backward compatibility with the version 3.1
* Standards-Version updated to 4.1.4
* Switch to debhelper level 11
* Use salsa.debian.org Vcs-* URLs
* Track and download the new releases from GitHub
-- Emmanuel Bourg <ebourg@apache.org> Wed, 13 Jun 2018 14:36:07 +0200
maven-shared-utils (3.1.0-2) unstable; urgency=medium
* Team upload.
......
......@@ -6,7 +6,7 @@ Uploaders:
Jakub Adam <jakub.adam@ktknet.cz>,
Kai-Chung Yan <seamlikok@gmail.com>
Build-Depends:
debhelper (>= 10),
debhelper (>= 11~),
default-jdk,
javahelper,
junit4,
......@@ -16,9 +16,9 @@ Build-Depends:
libmaven-javadoc-plugin-java,
libmaven-plugin-testing-java,
maven-debian-helper (>= 2.2~)
Standards-Version: 4.1.0
Vcs-Git: https://anonscm.debian.org/git/pkg-java/maven-shared-utils.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/maven-shared-utils.git
Standards-Version: 4.1.4
Vcs-Git: https://salsa.debian.org/java-team/maven-shared-utils.git
Vcs-Browser: https://salsa.debian.org/java-team/maven-shared-utils
Homepage: http://maven.apache.org/shared/maven-shared-utils/
Package: libmaven-shared-utils-java
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Maven Shared Utils
Upstream-Contact: Apache Maven team
Source: http://maven.apache.org/shared/maven-shared-utils/
Files: *
Copyright: 2012, The Apache Software Foundation
Copyright: 2012-2018, The Apache Software Foundation
License: Apache-2.0
Files: debian/*
......
#!/bin/sh -e
PACKAGE=$(dpkg-parsechangelog -S Source)
VERSION=$2
DIR=${PACKAGE}-${VERSION}
TAR=../${PACKAGE}_${VERSION}.orig.tar.xz
TAG=maven-shared-utils-$VERSION
svn export https://svn.apache.org/repos/asf/maven/shared/tags/$TAG/ $DIR
tar -c -J -f $TAR $DIR
rm -rf $DIR ../$TAG $3
Description: Restores the backward compatibility with maven-shared-utils 3.1
This patch is required to build Maven 3.5.3 with Maven 3.5.2. It can be dropped
once maven/3.5.3-1 is uploaded.
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/src/main/java/org/apache/maven/shared/utils/logging/MessageBuilder.java
+++ b/src/main/java/org/apache/maven/shared/utils/logging/MessageBuilder.java
@@ -27,6 +27,27 @@
public interface MessageBuilder
{
/**
+ * Append message content for DEBUG level.
+ * By default, bold cyan
+ */
+ @Deprecated
+ MessageBuilder debug( Object message );
+
+ /**
+ * Append message content for INFO level.
+ * By default, bold blue
+ */
+ @Deprecated
+ MessageBuilder info( Object message );
+
+ /**
+ * Append message content for ERROR level.
+ * By default, bold red
+ */
+ @Deprecated
+ MessageBuilder error( Object message );
+
+ /**
* Append message content in success style.
* By default, bold green
*/
--- a/src/main/java/org/apache/maven/shared/utils/logging/PlainMessageBuilder.java
+++ b/src/main/java/org/apache/maven/shared/utils/logging/PlainMessageBuilder.java
@@ -62,6 +62,24 @@
return a( level ).toString();
}
+ @Deprecated
+ public PlainMessageBuilder debug( Object message )
+ {
+ return a( message );
+ }
+
+ @Deprecated
+ public PlainMessageBuilder info( Object message )
+ {
+ return a( message );
+ }
+
+ @Deprecated
+ public PlainMessageBuilder error( Object message )
+ {
+ return a( message );
+ }
+
public PlainMessageBuilder success( Object message )
{
return a( message );
--- a/src/main/java/org/apache/maven/shared/utils/logging/AnsiMessageBuilder.java
+++ b/src/main/java/org/apache/maven/shared/utils/logging/AnsiMessageBuilder.java
@@ -70,6 +70,27 @@
return Style.ERROR.apply( ansi ).a( level ).reset().toString();
}
+ @Deprecated
+ public AnsiMessageBuilder debug( Object message )
+ {
+ Style.DEBUG.apply( ansi ).a( message ).reset();
+ return this;
+ }
+
+ @Deprecated
+ public AnsiMessageBuilder info( Object message )
+ {
+ Style.INFO.apply( ansi ).a( message ).reset();
+ return this;
+ }
+
+ @Deprecated
+ public AnsiMessageBuilder error( Object message )
+ {
+ Style.ERROR.apply( ansi ).a( message ).reset();
+ return this;
+ }
+
public AnsiMessageBuilder success( Object message )
{
Style.SUCCESS.apply( ansi ).a( message ).reset();
01-backward-compatibility.patch
version=3
opts="uversionmangle=s/-(alpha|beta)-/~$1/" \
https://svn.apache.org/repos/asf/maven/shared/tags/ maven-shared-utils-(\d.*)/ debian debian/orig-tar.sh
opts="repack,compression=xz,uversionmangle=s/-(alpha|beta)-/~$1/" \
https://github.com/apache/maven-shared-utils/tags .*/maven-shared-utils-(\d.*).tar.gz
......@@ -28,25 +28,25 @@
</parent>
<artifactId>maven-shared-utils</artifactId>
<version>3.1.0</version>
<version>3.2.1</version>
<name>Apache Maven Shared Utils</name>
<description>Shared utils without any further dependencies</description>
<prerequisites>
<maven>${mavenVersion}</maven>
</prerequisites>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/shared/tags/maven-shared-utils-3.1.0</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/shared/tags/maven-shared-utils-3.1.0
</developerConnection>
<url>http://svn.apache.org/viewvc/maven/shared/tags/maven-shared-utils-3.1.0</url>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-shared-utils.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-shared-utils.git</developerConnection>
<url>https://github.com/apache/maven-shared-utils/tree/${project.scm.tag}</url>
<tag>maven-shared-utils-3.2.1</tag>
</scm>
<issueManagement>
<system>jira</system>
<url>https://issues.apache.org/jira/browse/MSHARED/component/12326452</url>
</issueManagement>
<ciManagement>
<system>Jenkins</system>
<url>https://builds.apache.org/job/maven-box/job/maven-shared-utils/</url>
</ciManagement>
<distributionManagement>
<site>
<id>apache.website</id>
......@@ -108,7 +108,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<version>1.0-alpha-9-stable-1</version>
<version>1.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
......@@ -120,6 +120,20 @@
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
......
......@@ -39,7 +39,7 @@ import java.util.Set;
* @author Magesh Umasankar
* @author Brian Fox
* @author Mark Struberg
* @version $Revision: 1706295 $
* @version $Revision$
*
*/
public class Os
......
......@@ -49,7 +49,7 @@ import javax.annotation.Nullable;
* @author <a href="mailto:fredrik@westermarck.com">Fredrik Westermarck</a>
* @author Holger Krauth
* @author <a href="mailto:alex@purpletech.com">Alexander Day Chaffee</a>
* @version $Id: StringUtils.java 1706704 2015-10-04 17:35:19Z khmarbaise $
* @version $Id$
*
*/
public class StringUtils
......
......@@ -40,7 +40,7 @@ import javax.annotation.Nonnull;
* @author Hervé Boutemy
* @see java.nio.charset.Charset
* @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">Supported encodings</a>
* @version $Id: WriterFactory.java 1627926 2014-09-27 07:01:33Z hboutemy $
* @version $Id$
*/
public class WriterFactory
{
......
......@@ -21,7 +21,7 @@ package org.apache.maven.shared.utils.cli;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id: CommandLineException.java 1706704 2015-10-04 17:35:19Z khmarbaise $
* @version $Id$
*/
public class CommandLineException
extends Exception
......
......@@ -36,22 +36,28 @@ import org.apache.maven.shared.utils.StringUtils;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l </a>
* @version $Id: CommandLineUtils.java 1706704 2015-10-04 17:35:19Z khmarbaise $
* @version $Id$
*/
public abstract class CommandLineUtils
{
/**
* A {@code StreamConsumer} providing consumed lines as a {@code String}.
*
* @see #getOutput()
*/
public static class StringStreamConsumer
implements StreamConsumer
{
private final StringBuffer string = new StringBuffer();
private static final String LS = System.getProperty( "line.separator" );
private static final String LS = System.getProperty( "line.separator", "\n" );
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void consumeLine( String line )
{
string.append( line ).append( LS );
......@@ -64,27 +70,18 @@ public abstract class CommandLineUtils
{
return string.toString();
}
}
private static class ProcessHook
extends Thread
{
private final Process process;
private ProcessHook( Process process )
{
super( "CommandlineUtils process shutdown hook" );
this.process = process;
this.setContextClassLoader( null );
}
/** {@inheritDoc} */
public void run()
{
process.destroy();
}
}
/**
* Number of milliseconds per second.
*/
private static final long MILLIS_PER_SECOND = 1000L;
/**
* Number of nanoseconds per second.
*/
private static final long NANOS_PER_SECOND = 1000000000L;
/**
* @param cl The command line {@link Commandline}
......@@ -247,32 +244,48 @@ public abstract class CommandLineUtils
final Process p = cl.execute();
final StreamFeeder inputFeeder = systemIn != null ? new StreamFeeder( systemIn, p.getOutputStream() ) : null;
final StreamPumper outputPumper = new StreamPumper( p.getInputStream(), systemOut );
final StreamPumper errorPumper = new StreamPumper( p.getErrorStream(), systemErr );
final Thread processHook = new Thread()
{
if ( inputFeeder != null )
{
inputFeeder.start();
this.setName( "CommandLineUtils process shutdown hook" );
this.setContextClassLoader( null );
}
outputPumper.start();
errorPumper.start();
@Override
public void run()
{
p.destroy();
}
final ProcessHook processHook = new ProcessHook( p );
};
ShutdownHookUtils.addShutDownHook( processHook );
return new CommandLineCallable()
{
@Override
public Integer call()
throws CommandLineException
{
StreamFeeder inputFeeder = null;
StreamPumper outputPumper = null;
StreamPumper errorPumper = null;
try
{
if ( systemIn != null )
{
inputFeeder = new StreamFeeder( systemIn, p.getOutputStream() );
inputFeeder.start();
}
outputPumper = new StreamPumper( p.getInputStream(), systemOut );
outputPumper.start();
errorPumper = new StreamPumper( p.getErrorStream(), systemErr );
errorPumper.start();
int returnValue;
if ( timeoutInSeconds <= 0 )
{
......@@ -280,83 +293,123 @@ public abstract class CommandLineUtils
}
else
{
long now = System.currentTimeMillis();
long timeoutInMillis = 1000L * timeoutInSeconds;
long finish = now + timeoutInMillis;
while ( isAlive( p ) && ( System.currentTimeMillis() < finish ) )
final long now = System.nanoTime();
final long timeout = now + NANOS_PER_SECOND * timeoutInSeconds;
while ( isAlive( p ) && ( System.nanoTime() < timeout ) )
{
Thread.sleep( 10 );
// The timeout is specified in seconds. Therefore we must not sleep longer than one second
// but we should sleep as long as possible to reduce the number of iterations performed.
Thread.sleep( MILLIS_PER_SECOND - 1L );
}
if ( isAlive( p ) )
{
throw new InterruptedException(
"Process timeout out after " + timeoutInSeconds + " seconds" );
throw new InterruptedException( String.format( "Process timed out after %d seconds.",
timeoutInSeconds ) );
}
returnValue = p.exitValue();
}
if ( runAfterProcessTermination != null )
// TODO Find out if waitUntilDone needs to be called using a try-finally construct. The method may throw an
// InterruptedException so that calls to waitUntilDone may be skipped.
// try
// {
// if ( inputFeeder != null )
// {
// inputFeeder.waitUntilDone();
// }
// }
// finally
// {
// try
// {
// outputPumper.waitUntilDone();
// }
// finally
// {
// errorPumper.waitUntilDone();
// }
// }
if ( inputFeeder != null )
{
runAfterProcessTermination.run();
inputFeeder.waitUntilDone();
}
waitForAllPumpers( inputFeeder, outputPumper, errorPumper );
outputPumper.waitUntilDone();
errorPumper.waitUntilDone();
if ( inputFeeder != null )
{
inputFeeder.close();
if ( inputFeeder.getException() != null )
{
throw new CommandLineException( "Failure processing stdin.", inputFeeder.getException() );
}
}
if ( outputPumper.getException() != null )
{
throw new CommandLineException( "Error inside systemOut parser", outputPumper.getException() );
throw new CommandLineException( "Failure processing stdout.", outputPumper.getException() );
}
if ( errorPumper.getException() != null )
{
throw new CommandLineException( "Error inside systemErr parser", errorPumper.getException() );
throw new CommandLineException( "Failure processing stderr.", errorPumper.getException() );
}
return returnValue;
}
catch ( InterruptedException ex )
{
throw new CommandLineTimeOutException( "Error while executing external command, process killed.",
ex );
}
finally
{
if ( inputFeeder != null )
{
inputFeeder.disable();
}
if ( outputPumper != null )
{
outputPumper.disable();
}
if ( errorPumper != null )
{
errorPumper.disable();
throw new CommandLineTimeOutException( "Error while executing external command, process killed.",
ex );
}
try
{
if ( runAfterProcessTermination != null )
{
runAfterProcessTermination.run();
}
}
finally
{
ShutdownHookUtils.removeShutdownHook( processHook );
try
{
processHook.run();
}
finally
{
if ( inputFeeder != null )
{
inputFeeder.close();
}
outputPumper.close();
errorPumper.close();
}
}
};
}
private static void waitForAllPumpers( @Nullable StreamFeeder inputFeeder, StreamPumper outputPumper,
StreamPumper errorPumper )
throws InterruptedException
{
if ( inputFeeder != null )
{
inputFeeder.waitUntilDone();
}
outputPumper.waitUntilDone();
errorPumper.waitUntilDone();
};
}
/**
......
......@@ -19,16 +19,27 @@ package org.apache.maven.shared.utils.cli;
* under the License.
*/
import java.io.IOException;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: DefaultConsumer.java 1706704 2015-10-04 17:35:19Z khmarbaise $
* @version $Id$
*/
public class DefaultConsumer
implements StreamConsumer
{
/** {@inheritDoc} */
public void consumeLine( String line )
/**
* {@inheritDoc}
*/
@Override
public void consumeLine( String line ) throws IOException
{
System.out.println( line );
if ( System.out.checkError() )
{
throw new IOException( String.format( "Failure writing line '%s' to stdout.", line ) );
}
}
}
......@@ -19,6 +19,8 @@ package org.apache.maven.shared.utils.cli;
* under the License.
*/
import java.io.IOException;
/**
* Works in concert with the StreamPumper class to
* allow implementations to gain access to the lines being
......@@ -35,6 +37,7 @@ public interface StreamConsumer
/**
* Called when the StreamPumper pumps a line from the Stream.
* @param line The line to be consumed.
* @throws IOException if consuming {@code line} fails.
*/
void consumeLine( String line );
void consumeLine( String line ) throws IOException;
}
......@@ -28,30 +28,31 @@ import java.util.concurrent.atomic.AtomicReference;
* Read from an InputStream and write the output to an OutputStream.
*
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id: StreamFeeder.java 1703274 2015-09-15 19:20:31Z tibordigana $
* @version $Id$
*/
class StreamFeeder
extends AbstractStreamHandler
{
private final AtomicReference<InputStream> input;
private final AtomicReference<OutputStream> output;
private volatile Throwable exception;
/**
* Create a new StreamFeeder
*
* @param input Stream to read from
* @param output Stream to write to
*/
public StreamFeeder( InputStream input, OutputStream output )
StreamFeeder( InputStream input, OutputStream output )
{
super();
this.input = new AtomicReference<InputStream>( input );
this.output = new AtomicReference<OutputStream>( output );
}
// ----------------------------------------------------------------------
// Runnable implementation
// ----------------------------------------------------------------------
@Override
public void run()
{
......@@ -62,6 +63,10 @@ class StreamFeeder
catch ( Throwable e )
{
// Catch everything so the streams will be closed and flagged as done.
if ( this.exception != null )
{
this.exception = e;
}
}
finally
{
......@@ -74,10 +79,6 @@ class StreamFeeder
}
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public void close()
{
setDone();
......@@ -90,7 +91,10 @@ class StreamFeeder
}
catch ( IOException ex )
{
// ignore
if ( this.exception != null )
{
this.exception = ex;
}
}
}
......@@ -103,14 +107,21 @@ class StreamFeeder
}
catch ( IOException ex )
{
// ignore
if ( this.exception != null )
{
this.exception = ex;
}
}
}
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
/**
* @since 3.2.0
*/
public Throwable getException()
{
return this.exception;
}
@SuppressWarnings( "checkstyle:innerassignment" )
private void feed()
......@@ -118,6 +129,8 @@ class StreamFeeder
{
InputStream is = input.get();
OutputStream os = output.get();
boolean flush = false;
if ( is != null && os != null )
{
for ( int data; !isDone() && ( data = is.read() ) != -1; )
......@@ -125,7 +138,13 @@ class StreamFeeder
if ( !isDisabled() )
{
os.write( data );
flush = true;
}
}
if ( flush )
{
os.flush();
}
}
}
......
......@@ -23,14 +23,10 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.nio.charset.Charset;
import javax.annotation.Nullable;
import org.apache.maven.shared.utils.io.IOUtil;
/**
* Class to pump the error stream during Process's runtime. Copied from the Ant built-in task.
*
......@@ -44,8 +40,6 @@ public class StreamPumper
private final StreamConsumer consumer;
private final PrintWriter out;
private volatile Exception exception = null;
private static final int SIZE = 1024;
......@@ -56,7 +50,7 @@ public class StreamPumper
*/
public StreamPumper( InputStream in, StreamConsumer consumer )
{
this( new InputStreamReader( in ), null, consumer );
this( new InputStreamReader( in ), consumer );
}
/**
......@@ -66,18 +60,17 @@ public class StreamPumper
*/
public StreamPumper( InputStream in, StreamConsumer consumer, @Nullable Charset charset )
{
this( null == charset ? new InputStreamReader( in ) : new InputStreamReader( in, charset ), null, consumer );
this( null == charset ? new InputStreamReader( in ) : new InputStreamReader( in, charset ), consumer );
}
/**
* @param in {@link Writer}
* @param writer {@link PrintWriter}
* @param in {@link Reader}
* @param consumer {@link StreamConsumer}
*/
private StreamPumper( Reader in, PrintWriter writer, StreamConsumer consumer )
private StreamPumper( Reader in, StreamConsumer consumer )
{
super();
this.in = new BufferedReader( in, SIZE );
this.out = writer;
this.consumer = consumer;
}
......@@ -99,14 +92,6 @@ public class StreamPumper
{
exception = t;
}
if ( out != null )
{
out.println( line );
out.flush();
}
}
}
catch ( IOException e )
......@@ -115,7 +100,17 @@ public class StreamPumper
}
finally
{
IOUtil.close( in );
try
{
in.close();
}
catch ( final IOException e2 )
{
if ( this.exception == null )
{
this.exception = e2;
}
}
synchronized ( this )
{
......@@ -128,21 +123,24 @@ public class StreamPumper
/**
* flush.
*
* @deprecated As of 3.2.0, removed without replacement.
*/
@Deprecated
public void flush()
{
if ( out != null )
{
out.flush();
}
// Nothing to flush.
}
/**
* Close it.
*
* @deprecated As of 3.2.0, removed without replacement.
*/
@Deprecated
public void close()
{
IOUtil.close( out );
// Nothing to close.
}
/**
......@@ -153,7 +151,7 @@ public class StreamPumper
return exception;
}
private void consumeLine( String line )
private void consumeLine( String line ) throws IOException
{
if ( consumer != null && !isDisabled() )
{
......