diff --git a/plexus-compilers/plexus-compiler-jikes/pom.xml b/plexus-compilers/plexus-compiler-jikes/pom.xml deleted file mode 100644 index 9e1b3c58..00000000 --- a/plexus-compilers/plexus-compiler-jikes/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - - - org.codehaus.plexus - plexus-compilers - 2.10.0-SNAPSHOT - - - plexus-compiler-jikes - - Plexus Jikes Compiler - Jikes Compiler support for Plexus Compiler component. - - - - org.codehaus.plexus - plexus-utils - - - org.codehaus.plexus - plexus-component-annotations - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - - - - jikes-enabled - - - jikes-enabled - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - - - - diff --git a/plexus-compilers/plexus-compiler-jikes/src/main/java/org/codehaus/plexus/compiler/jikes/JikesCompiler.java b/plexus-compilers/plexus-compiler-jikes/src/main/java/org/codehaus/plexus/compiler/jikes/JikesCompiler.java deleted file mode 100644 index ef9b8ee5..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/main/java/org/codehaus/plexus/compiler/jikes/JikesCompiler.java +++ /dev/null @@ -1,477 +0,0 @@ -package org.codehaus.plexus.compiler.jikes; - -/** - * The MIT License - * - * Copyright (c) 2005, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/*============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ - - Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be - used to endorse or promote products derived from this software without - prior written permission. For written permission, please contact - apache@apache.org. - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation and was originally created by - Stefano Mazzocchi . For more information on the Apache - Software Foundation, please see . - -*/ - -import org.codehaus.plexus.compiler.AbstractCompiler; -import org.codehaus.plexus.compiler.Compiler; -import org.codehaus.plexus.compiler.CompilerConfiguration; -import org.codehaus.plexus.compiler.CompilerException; -import org.codehaus.plexus.compiler.CompilerMessage; -import org.codehaus.plexus.compiler.CompilerOutputStyle; -import org.codehaus.plexus.compiler.CompilerResult; -import org.codehaus.plexus.compiler.util.StreamPumper; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.util.Os; -import org.codehaus.plexus.util.StringUtils; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileFilter; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@Component( role = Compiler.class, hint = "jikes" ) -public class JikesCompiler - extends AbstractCompiler -{ - private static final int OUTPUT_BUFFER_SIZE = 1024; - - public JikesCompiler() - { - super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null ); - } - - // ----------------------------------------------------------------------- - // Compiler Implementation - // ----------------------------------------------------------------------- - - public CompilerResult performCompile( CompilerConfiguration config ) - throws CompilerException - { - // Ensures that the directory exist. - getDestinationDir( config ); - - try - { - // TODO: This should use the CommandLine stuff from plexus-utils. - - // ----------------------------------------------------------------------- - // Execute the compiler - // ----------------------------------------------------------------------- - - Process p = Runtime.getRuntime().exec( createCommandLine( config ) ); - - BufferedInputStream compilerErr = new BufferedInputStream( p.getErrorStream() ); - - ByteArrayOutputStream tmpErr = new ByteArrayOutputStream( OUTPUT_BUFFER_SIZE ); - StreamPumper errPumper = new StreamPumper( compilerErr, tmpErr ); - - errPumper.start(); - - p.waitFor(); - - int exitValue = p.exitValue(); - - // Wait until the complete error stream has been read - errPumper.join(); - - compilerErr.close(); - - p.destroy(); - - tmpErr.close(); - - // ----------------------------------------------------------------------- - // Parse the output - // ----------------------------------------------------------------------- - - BufferedReader input = - new BufferedReader( new InputStreamReader( new ByteArrayInputStream( tmpErr.toByteArray() ) ) ); - - List messages = new ArrayList<>(); - - parseStream( input, messages ); - - if ( exitValue != 0 && exitValue != 1 ) - { - messages.add( new CompilerMessage( "Exit code from jikes was not 0 or 1 ->" + exitValue, true ) ); - } - - return new CompilerResult().compilerMessages( messages ); - } - catch ( IOException | InterruptedException e ) - { - throw new CompilerException( "Error while compiling.", e ); - } - } - - public String[] createCommandLine( CompilerConfiguration config ) - throws CompilerException - { - List args = new ArrayList<>(); - - args.add( "jikes" ); - - String bootClassPath = getPathString( getBootClassPath() ); - getLogger().debug( "Bootclasspath: " + bootClassPath ); - if ( !StringUtils.isEmpty( bootClassPath ) ) - { - args.add( "-bootclasspath" ); - args.add( bootClassPath ); - } - - String classPath = getPathString( config.getClasspathEntries() ); - getLogger().debug( "Classpath: " + classPath ); - if ( !StringUtils.isEmpty( classPath ) ) - { - args.add( "-classpath" ); - args.add( classPath ); - } - - args.add( "+E" ); - - for ( Map.Entry arg : config.getCustomCompilerArgumentsAsMap().entrySet() ) - { - args.add( arg.getKey() ); - args.add( arg.getValue() ); - } - - - args.add( "-target" ); - if ( StringUtils.isNotEmpty( config.getTargetVersion() ) ) - { - args.add( config.getTargetVersion() ); - } - else - { - args.add( "1.1" ); - } - - args.add( "-source" ); - if ( StringUtils.isNotEmpty( config.getSourceVersion() ) ) - { - args.add( config.getSourceVersion() ); - } - else - { - args.add( "1.3" ); - } - - if ( !config.isShowWarnings() ) - { - args.add( "-nowarn" ); - } - - if ( config.isShowDeprecation() ) - { - args.add( "-deprecation" ); - } - - if ( config.isOptimize() ) - { - args.add( "-O" ); - } - - if ( config.isVerbose() ) - { - args.add( "-verbose" ); - } - - if ( config.isDebug() ) - { - args.add( "-g:lines" ); - } - - args.add( "-d" ); - - args.add( getDestinationDir( config ).getAbsolutePath() ); - - String sourcePath = getPathString( config.getSourceLocations() ); - getLogger().debug( "Source path:" + sourcePath ); - if ( !StringUtils.isEmpty( sourcePath ) ) - { - args.add( "-sourcepath" ); - args.add( sourcePath ); - } - - String[] sourceFiles = getSourceFiles( config ); - - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - String tempFileName = null; - try - { - File tempFile = File.createTempFile( "compList", ".cmp" ); - tempFileName = tempFile.getAbsolutePath(); - try (BufferedWriter fw = new BufferedWriter( new FileWriter( tempFile ) )) - { - - getLogger().debug( "create TempFile" + tempFileName ); - - tempFile.getParentFile().mkdirs(); - for ( String sourceFile : sourceFiles ) - { - fw.write( sourceFile ); - fw.newLine(); - } - tempFile.deleteOnExit(); - } - } - catch ( IOException e ) - { - throw new CompilerException( "Could not create temporary file " + tempFileName, e ); - } - - args.add( "@" + tempFileName ); - } - else - { - for ( String sourceFile : sourceFiles ) - { - args.add( sourceFile ); - } - - } - - return args.toArray( new String[args.size()] ); - } - - // ----------------------------------------------------------------------- - // Private - // ----------------------------------------------------------------------- - - private File getDestinationDir( CompilerConfiguration config ) - { - File destinationDir = new File( config.getOutputLocation() ); - - if ( !destinationDir.exists() ) - { - destinationDir.mkdirs(); - } - - return destinationDir; - } - - private List getBootClassPath() - { - List bootClassPath = new ArrayList<>(); - FileFilter filter = new FileFilter() - { - - public boolean accept( File file ) - { - String name = file.getName(); - return name.endsWith( ".jar" ) || name.endsWith( ".zip" ); - } - - }; - - File javaHomeDir = new File( System.getProperty( "java.home" ) ); - - File javaLibDir = new File( javaHomeDir, "lib" ); - if ( javaLibDir.isDirectory() ) - { - bootClassPath.addAll( asList( javaLibDir.listFiles( filter ) ) ); - } - - File javaClassesDir = new File( javaHomeDir, "../Classes" ); - if ( javaClassesDir.isDirectory() ) - { - bootClassPath.addAll( asList( javaClassesDir.listFiles( filter ) ) ); - } - - File javaExtDir = new File( javaLibDir, "ext" ); - if ( javaExtDir.isDirectory() ) - { - bootClassPath.addAll( asList( javaExtDir.listFiles( filter ) ) ); - } - - return bootClassPath; - } - - private List asList( File[] files ) - { - List filenames = new ArrayList<>( files.length ); - for ( File file : files ) - { - filenames.add( file.toString() ); - } - return filenames; - } - - /** - * Parse the compiler error stream to produce a list of - * CompilerMessages - * - * @param input The error stream - * @return The list of compiler error messages - * @throws IOException If an error occurs during message collection - */ - protected List parseStream( BufferedReader input, List messages ) - throws IOException - { - String line = null; - StringBuilder buffer; - - while ( true ) - { - // cleanup the buffer - buffer = new StringBuilder(); // this is faster than clearing it - - // first line is not space-starting - if ( line == null ) - { - line = input.readLine(); - } - - if ( line == null ) - { - return messages; - } - - buffer.append( line ); - - // all other space-starting lines are one error - while ( true ) - { - line = input.readLine(); - // EOF - if ( line == null ) - { - break; - } - // Continuation of previous error starts with ' ' - if ( line.length() > 0 && line.charAt( 0 ) != ' ' ) - { - break; - } - buffer.append( EOL ); - buffer.append( line ); - } - - if ( buffer.length() > 0 ) - { - // add the error bean - messages.add( parseError( buffer.toString() ) ); - } - } - } - - /** - * Parse an individual compiler error message - * - * @param error The error text - * @return A mssaged CompilerMessage - */ - private CompilerMessage parseError( String error ) - { - if ( error.startsWith( "Error:" ) ) - { - return new CompilerMessage( error, true ); - } - - String[] errorBits = StringUtils.split( error, ":" ); - - int i; - String file; - - if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) - { - file = errorBits[0] + ':' + errorBits[1]; - i = 2; - } - else - { - file = errorBits[0]; - i = 1; - } - - int startline = Integer.parseInt( errorBits[i++] ); - - int startcolumn = Integer.parseInt( errorBits[i++] ); - - int endline = Integer.parseInt( errorBits[i++] ); - - int endcolumn = Integer.parseInt( errorBits[i++] ); - - String type = errorBits[i++]; - - StringBuilder message = new StringBuilder( errorBits[i++] ); - while ( i < errorBits.length ) - { - message.append( ':' ).append( errorBits[i++] ); - } - - return new CompilerMessage( file, type.contains("Error"), startline, startcolumn, endline, endcolumn, - message.toString() ); - } -} diff --git a/plexus-compilers/plexus-compiler-jikes/src/site/site.xml b/plexus-compilers/plexus-compiler-jikes/src/site/site.xml deleted file mode 100644 index 38cbad8a..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/site/site.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/Bad.java b/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/Bad.java deleted file mode 100644 index b450e4f7..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/Bad.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.codehaus.foo; - -public class Bad -{ - // Intentionally misspelled modifier. - pubic String name; -} diff --git a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/Deprecation.java b/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/Deprecation.java deleted file mode 100644 index e2619472..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/Deprecation.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.codehaus.foo; - -public class Deprecation -{ - public Deprecation() - { - new java.util.Date("testDate"); - } -} diff --git a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/ExternalDeps.java b/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/ExternalDeps.java deleted file mode 100644 index 69afc95d..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/ExternalDeps.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.codehaus.foo; - - -import org.apache.commons.lang.StringUtils; - - -public class ExternalDeps -{ - - public void hello( String str ) - { - System.out.println( StringUtils.upperCase( str) ); - } -} diff --git a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/Person.java b/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/Person.java deleted file mode 100644 index 0b58d0ee..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/Person.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.codehaus.foo; - -public class Person -{ -} diff --git a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/ReservedWord.java b/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/ReservedWord.java deleted file mode 100644 index 3f8434fd..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/ReservedWord.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.codehaus.foo; - -public class ReservedWord -{ - String assert; -} diff --git a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/UnknownSymbol.java b/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/UnknownSymbol.java deleted file mode 100644 index d8b752e9..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/UnknownSymbol.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.codehaus.foo; - -public class UnknownSymbol -{ - public UnknownSymbol() - { - foo(); - } -} diff --git a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/WrongClassname.java b/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/WrongClassname.java deleted file mode 100644 index 1c4107f8..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/test-input/src/main/org/codehaus/foo/WrongClassname.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.codehaus.foo; - -public class RightClassname -{ -} diff --git a/plexus-compilers/plexus-compiler-jikes/src/test/java/org/codehaus/plexus/compiler/jikes/JikesCompilerTest.java b/plexus-compilers/plexus-compiler-jikes/src/test/java/org/codehaus/plexus/compiler/jikes/JikesCompilerTest.java deleted file mode 100644 index 532d0441..00000000 --- a/plexus-compilers/plexus-compiler-jikes/src/test/java/org/codehaus/plexus/compiler/jikes/JikesCompilerTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.codehaus.plexus.compiler.jikes; - -/** - * The MIT License - * - * Copyright (c) 2005, The Codehaus - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.util.Arrays; -import java.util.Collection; - -import org.codehaus.plexus.compiler.AbstractCompilerTest; -import org.junit.jupiter.api.BeforeEach; - -/** - * @author Jason van Zyl - */ -public class JikesCompilerTest - extends AbstractCompilerTest -{ - protected String getRoleHint() - { - return "jikes"; - } - - @BeforeEach - public void setUp() - throws Exception - { - setCompilerDebug( true ); - setCompilerDeprecationWarnings( true ); - } - - @Override - protected int expectedErrors() - { - return 2; - } - - @Override - protected int expectedWarnings() - { - return 3; - } - - @Override - protected Collection expectedOutputFiles() - { - return Arrays.asList( new String[]{ "org/codehaus/foo/Deprecation.class", "org/codehaus/foo/ExternalDeps.class", - "org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class", - "org/codehaus/foo/RightClassname.class" } ); - } - -} diff --git a/plexus-compilers/pom.xml b/plexus-compilers/pom.xml index 0793c1ff..ec03acd0 100644 --- a/plexus-compilers/pom.xml +++ b/plexus-compilers/pom.xml @@ -17,7 +17,6 @@ plexus-compiler-aspectj plexus-compiler-csharp plexus-compiler-eclipse - plexus-compiler-jikes plexus-compiler-javac plexus-compiler-javac-errorprone plexus-compiler-j2objc diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt index 5bdc150d..d31151aa 100644 --- a/src/site/apt/index.apt +++ b/src/site/apt/index.apt @@ -48,8 +48,6 @@ Plexus Compiler * {{{./plexus-compilers/plexus-compiler-javac-errorprone/}<<>>}}: javac compiler with {{{https://errorprone.info}error-prone}} static analysis checks enabled, - * {{{./plexus-compilers/plexus-compiler-jikes/}<<>>}}: jikes compiler, - [] * {{{./plexus-compiler-test/}<<>>}}: a test harness.