Author: asoldano
Date: 2015-03-20 07:43:04 -0400 (Fri, 20 Mar 2015)
New Revision: 19587
Modified:
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractToolsMojo.java
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/UrlUtils.java
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/WSContractDelegate.java
Log:
[JBWS-3824] Misc fixes/improvements:
* Fix indentation
* Remove unused methods
* Properly concatenate strings using StringBuilder
* Create temp file in dedicated output directory
Modified:
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractToolsMojo.java
===================================================================
---
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractToolsMojo.java 2015-03-20
11:04:45 UTC (rev 19586)
+++
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractToolsMojo.java 2015-03-20
11:43:04 UTC (rev 19587)
@@ -179,35 +179,32 @@
* @return The file pointint to the jar
* @throws java.io.IOException When a file operation fails.
*/
- public File createJar( List<String> classPath, String startClassName )
- throws IOException
+ public File createJar(List<String> classPath, String startClassName) throws
IOException
{
- File tempDirectory = getOutputDirectory();
+ File tempDirectory = new File(getOutputDirectory().getParentFile(),
"jaxws-tools");
tempDirectory.mkdirs();
- File file = File.createTempFile( "jbosswsJaxwsTools", ".jar",
tempDirectory );
+ File file = File.createTempFile("jaxws-tools-maven-plugin-classpath-",
".jar", tempDirectory);
- FileOutputStream fos = new FileOutputStream( file );
- JarOutputStream jos = new JarOutputStream( fos );
- jos.setLevel( JarOutputStream.STORED );
- JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" );
- jos.putNextEntry( je );
+ FileOutputStream fos = new FileOutputStream(file);
+ JarOutputStream jos = new JarOutputStream(fos);
+ jos.setLevel(JarOutputStream.STORED);
+ JarEntry je = new JarEntry("META-INF/MANIFEST.MF");
+ jos.putNextEntry(je);
Manifest man = new Manifest();
- // we can't use StringUtils.join here since we need to add a '/' to
- // the end of directory entries - otherwise the jvm will ignore them.
- String cp = "";
+ StringBuilder cp = new StringBuilder();
for ( String el : classPath )
{
- // NOTE: if File points to a directory, this entry MUST end in '/'.
- cp += UrlUtils.getURL(new File(el)).toExternalForm() + " ";
+ cp.append(UrlUtils.getURL(new File(el)).toExternalForm());
+ cp.append(" ");
}
- man.getMainAttributes().putValue( "Manifest-Version", "1.0" );
- man.getMainAttributes().putValue( "Class-Path", cp.trim() );
- man.getMainAttributes().putValue( "Main-Class", startClassName );
+ man.getMainAttributes().putValue("Manifest-Version", "1.0");
+ man.getMainAttributes().putValue("Class-Path", cp.toString().trim());
+ man.getMainAttributes().putValue("Main-Class", startClassName);
- man.write( jos );
+ man.write(jos);
jos.close();
return file;
Modified:
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/UrlUtils.java
===================================================================
---
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/UrlUtils.java 2015-03-20
11:04:45 UTC (rev 19586)
+++
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/UrlUtils.java 2015-03-20
11:43:04 UTC (rev 19587)
@@ -28,13 +28,14 @@
import java.util.BitSet;
/**
- * Utility for dealing with URLs in pre-JDK 1.4.
+ * Utility for dealing with URLs
*
- * User: rsearls
- * Date: 2/6/15
+ * @author rsearls
+ * @since 06-Feb-2015
*/
-public class UrlUtils {
- private static final BitSet UNRESERVED = new BitSet( Byte.MAX_VALUE - Byte.MIN_VALUE +
1 );
+public class UrlUtils
+{
+ private static final BitSet UNRESERVED = new BitSet(Byte.MAX_VALUE - Byte.MIN_VALUE +
1);
private static final int RADIX = 16;
@@ -50,50 +51,46 @@
{
try
{
- byte[] bytes =
-
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'():/".getBytes(
ENCODING );
- for ( byte aByte : bytes )
+ byte[] bytes =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'():/".getBytes(ENCODING);
+ for (byte aByte : bytes)
{
- UNRESERVED.set( aByte );
+ UNRESERVED.set(aByte);
}
}
- catch ( UnsupportedEncodingException e )
+ catch (UnsupportedEncodingException e)
{
// can't happen as UTF-8 must be present
}
}
- public static URL getURL( File file )
- throws MalformedURLException
+ public static URL getURL(File file) throws MalformedURLException
{
- // with JDK 1.4+, code would be: return new URL( file.toURI().toASCIIString() );
- //noinspection deprecation
- URL url = file.toURL();
+ URL url = new URL(file.toURI().toASCIIString());
// encode any characters that do not comply with RFC 2396
// this is primarily to handle Windows where the user's home directory contains
spaces
try
{
- byte[] bytes = url.toString().getBytes( ENCODING );
- StringBuilder buf = new StringBuilder( bytes.length );
- for ( byte b : bytes )
+ byte[] bytes = url.toString().getBytes(ENCODING);
+ StringBuilder buf = new StringBuilder(bytes.length);
+ for (byte b : bytes)
{
- if ( b > 0 && UNRESERVED.get( b ) )
+ if (b > 0 && UNRESERVED.get(b))
{
- buf.append( (char) b );
+ buf.append((char) b);
}
else
{
- buf.append( '%' );
- buf.append( Character.forDigit( b >>> 4 & MASK, RADIX ) );
- buf.append( Character.forDigit( b & MASK, RADIX ) );
+ buf.append('%');
+ buf.append(Character.forDigit(b >>> 4 & MASK, RADIX));
+ buf.append(Character.forDigit(b & MASK, RADIX));
}
}
- return new URL( buf.toString() );
+ return new URL(buf.toString());
}
- catch ( UnsupportedEncodingException e )
+ catch (UnsupportedEncodingException e)
{
// should not happen as UTF-8 must be present
- throw new RuntimeException( e );
+ throw new RuntimeException(e);
}
}
}
Modified:
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/WSContractDelegate.java
===================================================================
---
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/WSContractDelegate.java 2015-03-20
11:04:45 UTC (rev 19586)
+++
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/WSContractDelegate.java 2015-03-20
11:43:04 UTC (rev 19587)
@@ -24,7 +24,6 @@
import java.io.File;
import java.io.PrintStream;
import java.lang.reflect.Method;
-import java.net.URL;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -129,39 +128,6 @@
}
/**
- * Write list of archives on the command-line
- *
- * @param argLine
- * @param classpath
- * @param toolClass
- * @return
- */
- private static List<String> initCommandList(String argLine, List<String>
classpath, String toolClass)
- {
- List<String> commandList = new ArrayList<String>();
- commandList.add("java");
- if (argLine != null)
- {
- commandList.add(argLine);
- }
- List<String> cp = classpath;
- if (cp != null && !cp.isEmpty())
- {
- commandList.add("-classpath ");
- StringBuilder additionalClasspath = new StringBuilder();
- for (String c : cp)
- {
- additionalClasspath.append(c);
- additionalClasspath.append(File.pathSeparator);
- }
- additionalClasspath.deleteCharAt(additionalClasspath.length() - 1);
- commandList.add(additionalClasspath.toString());
- }
- commandList.add(toolClass);
- return commandList;
- }
-
- /**
* Write manifest-only jar to the command-line
*
* @param argLine
Show replies by date