From ff28cd6dc27e8fbb18c8b47ad4982620155b2c10 Mon Sep 17 00:00:00 2001 From: "Lincoln Baxter, III" Date: Mon, 22 Sep 2014 16:24:23 -0400 Subject: [PATCH] ROASTER-37: Added installable distribution for, and refactored, the Formatter --- api/pom.xml | 2 +- dist/pom.xml | 47 +++++ dist/src/main/assembly/assembly.xml | 28 +++ .../org/jboss/forge/roaster/Bootstrap.java | 130 +++++++++++++ dist/src/main/resources/ECLIPSE_LICENSE.txt | 84 ++++++++ dist/src/main/resources/bin/roaster | 162 ++++++++++++++++ dist/src/main/resources/bin/roaster.bat | 183 ++++++++++++++++++ dist/src/main/resources/img/forge.ico | Bin 0 -> 52946 bytes dist/src/main/resources/img/forge.png | Bin 0 -> 51405 bytes impl/pom.xml | 2 +- .../forge/roaster/model/util/Formatter.java | 178 +++++++++++++---- pom.xml | 1 + 12 files changed, 780 insertions(+), 37 deletions(-) create mode 100644 dist/pom.xml create mode 100644 dist/src/main/assembly/assembly.xml create mode 100644 dist/src/main/java/org/jboss/forge/roaster/Bootstrap.java create mode 100644 dist/src/main/resources/ECLIPSE_LICENSE.txt create mode 100755 dist/src/main/resources/bin/roaster create mode 100644 dist/src/main/resources/bin/roaster.bat create mode 100644 dist/src/main/resources/img/forge.ico create mode 100644 dist/src/main/resources/img/forge.png diff --git a/api/pom.xml b/api/pom.xml index 99285b07..df6ab6be 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -7,6 +7,6 @@ ../pom.xml roaster-api - Forge Roaster API + Forge Roaster - API diff --git a/dist/pom.xml b/dist/pom.xml new file mode 100644 index 00000000..8585c306 --- /dev/null +++ b/dist/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.jboss.forge.roaster + roaster-parent + 2.8.1-SNAPSHOT + ../pom.xml + + + roaster-distribution + Forge Roaster - Distribution + + + + org.jboss.forge.roaster + roaster-jdt + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + distribution + package + + single + + + false + + src/main/assembly/assembly.xml + + ${project.build.finalName} + + + + + + + diff --git a/dist/src/main/assembly/assembly.xml b/dist/src/main/assembly/assembly.xml new file mode 100644 index 00000000..447e5e8e --- /dev/null +++ b/dist/src/main/assembly/assembly.xml @@ -0,0 +1,28 @@ + + dist + + zip + + + ${project.build.finalName} + + + + + src/main/resources + / + + ** + + + + + + + /lib + true + + + + diff --git a/dist/src/main/java/org/jboss/forge/roaster/Bootstrap.java b/dist/src/main/java/org/jboss/forge/roaster/Bootstrap.java new file mode 100644 index 00000000..50eabdac --- /dev/null +++ b/dist/src/main/java/org/jboss/forge/roaster/Bootstrap.java @@ -0,0 +1,130 @@ +package org.jboss.forge.roaster; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.ExecutionException; + +import org.jboss.forge.roaster.model.util.Formatter; + +public class Bootstrap +{ + public static void main(final String[] args) throws InterruptedException, ExecutionException, IOException + { + final List bootstrapArgs = new ArrayList(); + final Properties systemProperties = System.getProperties(); + // Set system properties + for (String arg : args) + { + if (arg.startsWith("-D")) + { + final String name; + final String value; + final int index = arg.indexOf("="); + if (index == -1) + { + name = arg.substring(2); + value = "true"; + } + else + { + name = arg.substring(2, index); + value = arg.substring(index + 1); + } + systemProperties.setProperty(name, value); + } + else + { + bootstrapArgs.add(arg); + } + } + + Bootstrap bootstrap = new Bootstrap(); + bootstrap.run(bootstrapArgs); + } + + private void run(List args) throws IOException + { + if (args.size() > 0) + { + if (args.contains("--help") || args.contains("-h")) + { + System.out.println(help()); + return; + } + + boolean recursive = false; + String configFile = null; + List files = new ArrayList(); + for (int i = 0; i < args.size(); i++) + { + String arg = args.get(i); + if ("--config".equals(arg) || "-c".equals(arg)) + { + configFile = args.get(++i); + if (!new File(configFile).isFile()) + { + System.out.println("roaster: configuration file [" + configFile + "] does not exist."); + return; + } + } + else if ("--recursive".equals(arg) || "-r".equals(arg)) + { + recursive = true; + } + else if (new File(arg).exists()) + { + files.add(new File(arg)); + } + else + { + System.out.println("roaster: no such file: '" + arg + "'"); + System.out.println("Try 'roaster --help' for more information."); + } + } + + format(files, configFile, recursive); + } + } + + private void format(List files, String configFile, boolean recursive) throws IOException + { + for (File file : files) + { + if (file.isDirectory()) + { + format(Arrays.asList(file.listFiles()), configFile, recursive); + } + else if (file.getName().endsWith(".java")) + { + if (configFile != null) + Formatter.format(new File(configFile), file); + else + Formatter.format(file); + } + } + } + + private String help() + { + StringBuilder sb = new StringBuilder(); + sb.append("Usage: roaster [OPTION]... FILES ... \n"); + sb.append("The fastest way to build applications, share your software, and enjoy doing it. \n"); + sb.append("\n"); + sb.append("-c, --config [CONFIG_FILE]\n"); + sb.append("\t specify the path to the Eclipse code format profile (usually found at '$PROJECT/.settings/org.eclipse.jdt.core.prefs') \n"); + sb.append("\n"); + sb.append("-r, --recursive\n"); + sb.append("\t format files in found sub-directories recursively \n"); + sb.append("\n"); + sb.append("FILES... \n"); + sb.append("\t specify one or more space-separated files or directories to format \n"); + sb.append("\n"); + sb.append("-h, --help\n"); + sb.append("\t display this help and exit \n"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/dist/src/main/resources/ECLIPSE_LICENSE.txt b/dist/src/main/resources/ECLIPSE_LICENSE.txt new file mode 100644 index 00000000..9381715a --- /dev/null +++ b/dist/src/main/resources/ECLIPSE_LICENSE.txt @@ -0,0 +1,84 @@ +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT’S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + + a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and + b) in the case of each subsequent Contributor: + + i)changes to the Program, and + + ii)additions to the Program; + + where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor’s behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient’s responsibility to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + + a) it complies with the terms and conditions of this Agreement; and + + b) its license agreement: + + i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; + + ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; + + iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and + + iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + + a) it must be made available under this Agreement; and + + b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the Program. + +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor’s responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), 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 OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient’s patent(s), then such Recipient’s rights granted under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient’s rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient’s rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient’s obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. \ No newline at end of file diff --git a/dist/src/main/resources/bin/roaster b/dist/src/main/resources/bin/roaster new file mode 100755 index 00000000..b270cff7 --- /dev/null +++ b/dist/src/main/resources/bin/roaster @@ -0,0 +1,162 @@ +#!/bin/sh + +# ---------------------------------------------------------------------------- +# Copyright 2012 Red Hat, Inc. and/or its affiliates. +# +# Licensed under the Eclipse Public License version 1.0, available at +# http://www.eclipse.org/legal/epl-v10.html +# ---------------------------------------------------------------------------- + + + +# ---------------------------------------------------------------------- +# Roaster Startup script +# +# Required Environment vars: +# ------------------ +# JAVA_HOME - location of a JRE home directory +# +# Optional Environment Variables +# ------------------ +# ROASTER_HOME - location of Roaster's installed home dir +# ROASTER_OPTS - parameters passed to the Java VM when running Roaster +# ----------------------------------------------------------------------- +ROASTER_DEBUG_ARGS="" +QUOTED_ARGS="" + +while [ "$1" != "" ] ; do + + if [ "$1" = "--debug" ] ; then + ROASTER_DEBUG_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" + fi + + QUOTED_ARGS="$QUOTED_ARGS \"$1\"" + shift + +done + +if [ -f /etc/roasterrc ] ; then + . /etc/roasterrc +fi + +if [ -f "$HOME/.roasterrc" ] ; then + . "$HOME/.roasterrc" +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + if [ -z "$JAVA_VERSION" ] ; then + JAVA_VERSION="1.7+" + fi + if [ -z "$JAVA_HOME" ] ; then + JAVA_HOME="`/usr/libexec/java_home --version $JAVA_VERSION`" + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$ROASTER_HOME" ] ; then + ## resolve links - $0 may be a link to Roaster's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + ROASTER_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + ROASTER_HOME=`cd "$ROASTER_HOME" && pwd` + + cd "$saveddir" + echo Using Roaster at $ROASTER_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$ROASTER_HOME" ] && + ROASTER_HOME=`cygpath --unix "$ROASTER_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$ROASTER_HOME" ] && + ROASTER_HOME="`(cd "$ROASTER_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." + echo " We cannot execute $JAVACMD" + exit 1 +fi + +JAVAVER=`"$JAVACMD" -version 2>&1` +case $JAVAVER in +*1.[7-9]*) ;; +*1.[1-6]*) + echo " Error: a Java 1.7 or higher JRE is required to run Roaster; found [$JAVACMD -version == $JAVAVER]." + exit 1 + ;; +esac + + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +ROASTER_MAIN_CLASS=org.jboss.forge.roaster.Bootstrap + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$ROASTER_HOME" ] && + ROASTER_HOME=`cygpath --path --windows "$ROASTER_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$HOME" ] && + HOME=`cygpath --path --windows "$HOME"` +fi + +roaster_exec_cmd="\"$JAVACMD\" $ROASTER_DEBUG_ARGS $ROASTER_OPTS \"-Droaster.home=${ROASTER_HOME}\" \ + -cp \"${ROASTER_HOME}/lib/*\" $ROASTER_MAIN_CLASS" + +eval $roaster_exec_cmd "$QUOTED_ARGS" diff --git a/dist/src/main/resources/bin/roaster.bat b/dist/src/main/resources/bin/roaster.bat new file mode 100644 index 00000000..345e94ac --- /dev/null +++ b/dist/src/main/resources/bin/roaster.bat @@ -0,0 +1,183 @@ +@REM ---------------------------------------------------------------------------- +@REM Copyright 2012 Red Hat, Inc. and/or its affiliates. +@REM +@REM Licensed under the Eclipse Public License version 1.0, available at +@REM http://www.eclipse.org/legal/epl-v10.html +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Roaster Startup script +@REM +@REM Required Environment vars: +@REM ------------------ +@REM JAVA_HOME - location of a JRE home dir +@REM +@REM Optional Environment vars +@REM ------------------ +@REM ROASTER_HOME - location of Roaster's installed home dir +@REM ROASTER_OPTS - parameters passed to the Java VM when running Roaster +@REM ---------------------------------------------------------------------------- + +@echo off + +@REM set %USERHOME% to equivalent of $HOME +if not "%USERHOME%" == "" goto OkUserhome +set "USERHOME=%USERPROFILE%" + +if not "%USERHOME%" == "" goto OkUserhome +set "USERHOME=%HOMEDRIVE%%HOMEPATH%" + +:OkUserhome + +@REM Execute a user defined script before this one +if exist "%USERHOME%\roasterrc_pre.bat" call "%USERHOME%\roasterrc_pre.bat" + +set ERROR_CODE=0 + +@REM set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" @setlocal +if "%OS%"=="WINNT" @setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo ERROR: JAVA_HOME not found in your environment. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto chkJVersion + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory. +echo JAVA_HOME = "%JAVA_HOME%" +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation +echo. +goto error + +:chkJVersion +set PATH="%JAVA_HOME%\bin";%PATH% + +for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do ( + set JAVAVER=%%g +) +for /f "delims=. tokens=1-3" %%v in ("%JAVAVER%") do ( + set JAVAVER_MINOR=%%w +) + +if %JAVAVER_MINOR% geq 7 goto chkFHome + +echo. +echo A Java 1.7 or higher JRE is required to run Roaster. "%JAVA_HOME%\bin\java.exe" is version %JAVAVER% +echo. +goto error + +:chkFHome +if not "%ROASTER_HOME%"=="" goto valFHome + +if "%OS%"=="Windows_NT" SET "ROASTER_HOME=%~dp0.." +if "%OS%"=="WINNT" SET "ROASTER_HOME=%~dp0.." +if not "%ROASTER_HOME%"=="" goto valFHome + +echo. +echo ERROR: ROASTER_HOME not found in your environment. +echo Please set the ROASTER_HOME variable in your environment to match the +echo location of the Roaster installation +echo. +goto error + +:valFHome + +:stripFHome +if not "_%ROASTER_HOME:~-1%"=="_\" goto checkFBat +set "ROASTER_HOME=%ROASTER_HOME:~0,-1%" +goto stripFHome + +:checkFBat +if exist "%ROASTER_HOME%\bin\roaster.bat" goto init + +echo. +echo ERROR: ROASTER_HOME is set to an invalid directory. +echo ROASTER_HOME = "%ROASTER_HOME%" +echo Please set the ROASTER_HOME variable in your environment to match the +echo location of the Roaster installation +echo. +goto error +@REM ==== END VALIDATION ==== + +@REM Initializing the argument line +:init +setlocal enableextensions enabledelayedexpansion +set ROASTER_CMD_LINE_ARGS= +set ROASTER_DEBUG_ARGS= + +if "%1"=="" goto initArgs + +set "args=%*" +set "args=%args:,=:comma:%" +set "args=%args:;=:semicolon:%" + +for %%x in (%args%) do ( + set "arg=%%~x" + set "arg=!arg::comma:=,!" + set "arg=!arg::semicolon:=;!" + if "!arg!"=="--debug" set ROASTER_DEBUG_ARGS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 + set "ROASTER_CMD_LINE_ARGS=!ROASTER_CMD_LINE_ARGS! "!arg!"" +) + +:initArgs +setlocal enableextensions enabledelayedexpansion +if %1a==a goto endInit + +shift +goto initArgs +@REM Reaching here means variables are defined and arguments have been captured +:endInit + +SET ROASTER_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +@REM -- 4NT shell +if "%@eval[2+2]" == "4" goto 4NTCWJars + +goto runRoaster + +@REM Start Roaster +:runRoaster + +set ROASTER_MAIN_CLASS=org.jboss.forge.roaster.Bootstrap +%ROASTER_JAVA_EXE% %ROASTER_DEBUG_ARGS% %ROASTER_OPTS% "-Droaster.standalone=true" "-Droaster.home=%ROASTER_HOME%" ^ + -cp ".;%ROASTER_HOME%\lib\*" %ROASTER_MAIN_CLASS% %ROASTER_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +if "%OS%"=="Windows_NT" @endlocal +if "%OS%"=="WINNT" @endlocal +set ERROR_CODE=1 + +:end +@REM set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" goto endNT +if "%OS%"=="WINNT" goto endNT + +@REM For old DOS remove the set variables from ENV - we assume they were not set +@REM before we started - at least we don't leave any baggage around +set ROASTER_JAVA_EXE= +set ROASTER_CMD_LINE_ARGS= +goto postExec + +:endNT +@endlocal & set ERROR_CODE=%ERROR_CODE% + +:postExec +if exist "%USERHOME%\roasterrc_post.bat" call "%USERHOME%\roasterrc_post.bat" + +if "%ROASTER_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% + + diff --git a/dist/src/main/resources/img/forge.ico b/dist/src/main/resources/img/forge.ico new file mode 100644 index 0000000000000000000000000000000000000000..e679cb69061d3ca1f05b64e35267c41a63a91d15 GIT binary patch literal 52946 zcmeI5d34p~naAIodvEp)60#tWuwz*SWY|O!M7zkeW#+WB)}^*qouX|=iyDONkg&+A zsDPA3+_htEi(Q;kYR{b0`J+7@XF4)HQ`-va)LKvVv>Fj%KHvBL-kV=;Zjzgrkc8Zq z^YHH5^L?M^UGFc(1o(H$Er$Qg&2zsrrpOpG1tQ423@JQmk{n2KAjyFw2a+5}av;fp zBnOflNOB;_fg}ey=RnAd4u;GK+=ZQ|PR0&Y4uk^c)^NalCm1l#faBdkV=8HD-au_{ zvR%eRWzU!yDaJe%PBD*y<5OVw1pX(mU(p7ThHl{Edy0c36(*htAAC@?rmE^`{7sP7s17HGqqT*thp%kmD7n>oR`@+ZJ&!|AQ|AN3UrJd8P||!z z4#3aH;O~RN${C8BPq@}Nhg_K7Zft1SPa5GV{i^v;aw!sS&bIgwZ|766vp7<&aJ2I; zX%)9Im}2JPPVPN>fMrU+d>np02w(RLqd)xN4?m!o4GMz}!{38`?BcoWYisu@4k!XKJJGOSYC>!f$m|ba-3P$*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!~JM}5+-_K#7+Mx^x{wh6UM|HoGj zR}L9EgeP8k=>?Xcf~|@}t6p~5WnaCAY}ax8Z0XYFd_&B|Iqu;`iuQz%4e&IU3cvVT z{1B#!20**Z&Hllu79#HewDTzaALuMA#tMKUevBG6BCX%>4m_@X_2pM1?t_wY9<=bF zaZokIu(SU~Jcn5(7z-WMzXxU&9DqSj$G`rJHQ7TjEfX(iM(A>pYW8Oy2V>XOG z5JUFDfZOkX|Ind5xvDQV0Ng_2Ia?_!NtOkQXsaXjSSeo8#$vPmFpiuIig$m+`AH;g zwK9%}V0-a+AheT4FSQR$zYdj#qy?{U+qP|UeSQ76kw6C!3yDOUE%cH+J5dA1@Y-4-`dfqq-eqIuCEe9&kJz&a|sVCfY^DO{pgF2-E z93WT#tLXp_+40TzCm?l95yBFHdUX5%C~C)_B#P?J;QcMkKapktod4>&b#HFod+!GB zg`>q&os`1@r+MHL0CykhPjRhGdqfz=AZj?*+{`-!JlOEdYsmWZYmsY=cncgWCLvRS zkQELKoc8VPabX;T*aHhE!7c*lcq9!&#r~aypCg_4UHQXK6Jb1Xpk!nxJm!k_dt&2( z=m{DpI55G12@Z?{4%9q)E4EA~slO304#=G#ae@OA9GKw11P3NKFu{SL=D#2X) V`k-Dv;6vVje#%L|c>kGK|3B$A0u}%O literal 0 HcmV?d00001 diff --git a/impl/pom.xml b/impl/pom.xml index 59f99e3a..c6ab85a7 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -7,7 +7,7 @@ ../pom.xml roaster-jdt - Forge Roaster JDT Implementation + Forge Roaster - JDT Implementation org.jboss.forge.roaster diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/util/Formatter.java b/impl/src/main/java/org/jboss/forge/roaster/model/util/Formatter.java index b1f18d95..48266d97 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/util/Formatter.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/util/Formatter.java @@ -8,9 +8,18 @@ package org.jboss.forge.roaster.model.util; import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Map.Entry; import java.util.Properties; +import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.ToolFactory; import org.eclipse.jdt.core.formatter.CodeFormatter; import org.eclipse.jface.text.BadLocationException; @@ -18,32 +27,96 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.text.edits.TextEdit; import org.jboss.forge.roaster.model.source.JavaClassSource; +import org.jboss.forge.roaster.spi.Streams; /** + * Formats Java source code. + * * @author Lincoln Baxter, III */ public abstract class Formatter { + /** + * Format the given Java source {@link File}, using the built in code format style. + * + * @throws IOException When the file cannot be read or written + */ + public static void format(File source) throws IOException + { + format(null, source); + } + + /** + * Format the given Java source {@link File} using the given Eclipse code format properties {@link File}. + * + * @throws IOException When the file cannot be read or written, or the preferences cannot be read. + */ + public static void format(File prefs, File source) throws IOException + { + Properties options = readConfig(prefs); + if (options == null) + options = readConfigInternal("org.eclipse.jdt.core.prefs"); + + InputStream in = null; + OutputStream out = null; + try + { + in = new BufferedInputStream(new FileInputStream(source)); + String content = Streams.toString(in); + String formatted = format(options, content); + + out = new BufferedOutputStream(new FileOutputStream(source)); + Streams.write(new ByteArrayInputStream(formatted.getBytes()), out); + } + finally + { + Streams.closeQuietly(in); + Streams.closeQuietly(out); + } + + } + + /** + * Format the given {@link JavaClassSource}, using the built in code format style. + */ public static String format(JavaClassSource javaClass) { return format(javaClass.toString()); } - + + /** + * Format the given {@link JavaClassSource}, using the given Eclipse code format {@link Properties}. + */ + public static String format(Properties prefs, JavaClassSource javaClass) + { + return format(prefs, javaClass.toString()); + } + + /** + * Format the given {@link String} as a Java source file, using the built in code format style. + */ public static String format(String source) { - // TODO locate user's eclipse project settings, use those if we can. - Properties options = readConfig("org.eclipse.jdt.core.prefs"); + Properties options = readConfigInternal("org.eclipse.jdt.core.prefs"); + return format(options, source); + } - final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options); - return ensureCorrectNewLines(formatFile(source, codeFormatter)); + /** + * Format the given {@link String} as a Java source type, using the given Eclipse code format {@link Properties}. + */ + public static String format(Properties prefs, String source) + { + final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(prefs); + return _format(source, codeFormatter); } - private static String formatFile(String contents, CodeFormatter codeFormatter) + private static String _format(String contents, CodeFormatter codeFormatter) { IDocument doc = new Document(contents); try { - TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, contents, 0, contents.length(), 0, null); + TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, + contents, 0, contents.length(), 0, null); if (edit != null) { edit.apply(doc); @@ -58,48 +131,83 @@ private static String formatFile(String contents, CodeFormatter codeFormatter) throw new RuntimeException(e); } - return doc.get(); + return ensureCorrectNewLines(doc.get()); } - private static Properties readConfig(String filename) + private static Properties readConfig(File prefs) throws IOException { - BufferedInputStream stream = null; + if (prefs != null) + { + InputStream stream = new BufferedInputStream(new FileInputStream(prefs)); + try + { + Properties config = parseConfig(stream); + Properties modified = new Properties(); + for (Entry property : config.entrySet()) + { + String shadePackage = JavaCore.class.getPackage().getName().replaceAll("org\\.eclipse.*$", ""); + modified.put(shadePackage + property.getKey(), property.getValue()); + } + + return modified; + } + catch (IOException e) + { + throw new IOException("Error reading preferences file: [" + + prefs.getAbsolutePath() + "]", e); + } + finally + { + Streams.closeQuietly(stream); + } + } + + return null; + } + + private static Properties readConfigInternal(String filename) + { + InputStream stream = new BufferedInputStream(org.jboss.forge.roaster.model.util.Formatter.class + .getResourceAsStream(filename)); try { - stream = new BufferedInputStream(Formatter.class.getResourceAsStream(filename)); - final Properties formatterOptions = new Properties(); - formatterOptions.load(stream); - return formatterOptions; + return parseConfig(stream); } catch (IOException e) { - throw new RuntimeException(e); + throw new RuntimeException("Error reading internal configuration: [" + + filename + "]", e); } finally { - if (stream != null) - { - try - { - stream.close(); - } - catch (IOException e) - { - /* ignore */ - } - } + Streams.closeQuietly(stream); } } - - - private static String ensureCorrectNewLines(String documentString) + + private static Properties parseConfig(InputStream stream) + throws IOException { - String newLine = System.getProperty("line.separator"); - - if (documentString.indexOf("\n") != -1 && documentString.indexOf(newLine) == -1) - return documentString.replaceAll("\n", newLine); - - return documentString; + try + { + final Properties formatterOptions = new Properties(); + formatterOptions.load(stream); + return formatterOptions; + } + finally + { + Streams.closeQuietly(stream); + } + } + + private static String ensureCorrectNewLines(String content) + { + String newLine = System.getProperty("line.separator"); + + if (content.indexOf("\n") != -1 + && content.indexOf(newLine) == -1) + return content.replaceAll("\n", newLine); + + return content; } } diff --git a/pom.xml b/pom.xml index 1f446911..1771052b 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,7 @@ api impl + dist