Skip to content

Commit

Permalink
Fix the runtime example scripts #1944 (#1945)
Browse files Browse the repository at this point in the history
  • Loading branch information
wimjongman authored Oct 21, 2024
1 parent a739626 commit ce5ac95
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 70 deletions.
22 changes: 14 additions & 8 deletions build/org.eclipse.birt.releng.birtbuilder/extras/genReport.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
@ECHO off
setlocal

REM # Copyright (c) 2011, 2024, Actuate, Remain Software and others
REM #
REM # This program and the accompanying materials are made available under the
REM # terms of the Eclipse Public License 2.0 which is available at
REM # https://www.eclipse.org/legal/epl-2.0/.
REM #
REM # SPDX-License-Identifier: EPL-2.0

PUSHD %~dp0
set THIS_DIR=%CD%
POPD
Expand All @@ -11,28 +19,27 @@ if not [%1]==[] goto run

:usage
REM ################## USAGE OF REPORT ENGINE ################
echo.
echo example: genReport.bat -f PDF -o hello.pdf -p "paramList=1" -p "paramInteger=123" -p "paramString=Hello, Birt" samples\hello_world.rptdesign
echo.
echo org.eclipse.birt.report.engine.impl.ReportRunner Usage:
echo --mode/-m [ runrender ^| render ^| run] the default is runrender
echo.
echo For runrender mode:
echo we should add it in the end ^<design file^>
echo --format/-f [ HTML ^| PDF ]
echo --output/-o ^<target file^>
echo --output/-o ^<target directory^>
echo --htmlType/-t ^< HTML ^| ReportletNoCSS ^>
echo --locale/-l ^<locale^>
echo --parameter/-p ^<"parameterName=parameterValue"^>
echo --file/-F ^<parameter file^>
echo --encoding/-e ^<target encoding^>
echo.
echo example: genReport.bat -m runrender -f PDF samples\hello_world.rptdesign
echo.
echo Locale: default is English
echo parameters in command line will overide parameters in parameter file
echo parameter name cannot include characters such as ' ', '=', ':'
echo.
echo For RUN mode:
echo we should add it in the end ^<design file^>
echo --output/-o ^<target file^>
echo --output/-o ^<target directory^>
echo --locale/-l ^<locale^>
echo --parameter/-p ^<"parameterName=parameterValue"^>
echo --file/-F ^<parameter file^>
Expand All @@ -42,8 +49,7 @@ echo parameters in command line will overide parameters in parameter file
echo parameter name cannot include characters such as ' ', '=', ':'
echo.
echo For RENDER mode:
echo we should add it in the end ^<design file^>
echo --output/-o ^<target file^>
echo --output/-o ^<target directory^>
echo --page/-p ^<pageNumber^>
echo --locale/-l ^<locale^>
echo.
Expand Down
144 changes: 89 additions & 55 deletions build/org.eclipse.birt.releng.birtbuilder/extras/genReport.sh
Original file line number Diff line number Diff line change
@@ -1,66 +1,100 @@
#!/bin/sh
#!/bin/bash

################ USAGE OF REPORTRUNNER #########################
# org.eclipse.birt.report.engine.impl.ReportRunner Usage:
# --mode/-m [ run | render | runrender] the default is runrender
# for runrender mode:
# we should add it in the end <design file>
# --format/-f [ HTML | PDF ]
# --output/-o <target file>
# --htmlType/-t < HTML | ReportletNoCSS >
# --locale/-l<locale>
# --parameter/-p <"parameterName=parameterValue">
# --file/-F <parameter file>
# --encoding/-e <target encoding>
# Copyright (c) 2011, 2024, Actuate, Remain Software and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/.
#
# Locale: default is English
# parameters in command line will overide parameters in parameter file
# parameter name cannot include characters such as \' \'\, \'=\'\, \':\'
#
# For RUN mode:
# we should add it in the end <design file>
# --output/-o <target file>
# --locale/-l<locale>
# --parameter/-p <parameterName=parameterValue>
# --file/-F <parameter file>
#
# Locale: default is English
# parameters in command line will overide parameters in parameter file
# parameter name cannot include characters such as \' \'\, \'=\'\, \':\'
#
# For RENDER mode:
# we should add it in the end <design file>
# --output/-o <target file>
# --page/-p <pageNumber>
# --locale/-l<locale>
#
# Locale: default is English
################ END OF USAGE #########################
# SPDX-License-Identifier: EPL-2.0

# echo set common variables
#export BIRT_HOME=BIRT-runtime_install_dir
BIRT_HOME=""
WORK_DIR=$PWD
# class path : don't forget to add your connection drivers in the classpath directory
BIRTCLASSPATH=$BIRT_HOME/ReportEngine/lib/*
set -e

# Get the directory of the script
THIS_DIR=$(dirname "$(realpath "$0")")

echo BIRT_HOME=$BIRT_HOME
echo WORK_DIR=$WORK_DIR
echo BIRTCLASSPATH=$BIRTCLASSPATH
# Usage function
usage() {
echo
echo "genReport.sh calls the BIRT ReportRunner"
echo "example: ./genReport.sh -f PDF -o hello.pdf -p \"paramList=1\" -p \"paramInteger=123\" -p \"paramString=\\\"Hello,Birt\\\"\" samples/hello_world.rptdesign"
echo "--help this help"
echo
echo "org.eclipse.birt.report.engine.impl.ReportRunner Usage:"
echo "--mode/-m [ runrender | render | run ] the default is runrender"
echo
echo "For runrender mode:"
echo " --help runrender"
echo " --format/-f [ HTML | PDF ]"
echo " --output/-o <target file>"
echo " --htmlType/-t < HTML | ReportletNoCSS >"
echo " --locale/-l <locale>"
echo " --parameter/-p <\"parameterName=parameterValue\">"
echo " --file/-F <parameter file>"
echo " --encoding/-e <target encoding>"
echo
echo "Locale: default is English"
echo "parameters in command line will override parameters in parameter file"
echo "parameter name cannot include characters such as ' ', '=', ':'"
echo
echo "For RUN mode:"
echo " --help run"
echo " --output/-o <target file>"
echo " --locale/-l <locale>"
echo " --parameter/-p <\"parameterName=parameterValue\">"
echo " --file/-F <parameter file>"
echo
echo "Locale: default is English"
echo "parameters in command line will override parameters in parameter file"
echo "parameter name cannot include characters such as ' ', '=', ':'"
echo
echo "For RENDER mode:"
echo " --help render"
echo " --output/-o <target file>"
echo " --page/-p <pageNumber>"
echo " --locale/-l <locale>"
echo
echo "Locale: default is English"
}

if [ "$BIRT_HOME" = "" ]
# Run function
run() {
# Set common variables
WORK_DIR="$THIS_DIR"

then
echo "BIRT_HOME must be set before ReportRunner can run";
else
if [[ -d "$THIS_DIR/platform" ]]; then
BIRT_HOME="$THIS_DIR/platform"
fi

if [[ -n "$BIRT_HOME" ]]; then
echo "OSGI-Mode, BIRT_HOME=$BIRT_HOME"
fi

java_io_tmpdir=$WORK_DIR/tmpdir
org_eclipse_datatools_workspacepath=$java_io_tmpdir/workspace_dtp
mkdir -p $org_eclipse_datatools_workspacepath
# Set temporary directories
export java_io_tmpdir="$WORK_DIR/tmpdir"
export org_eclipse_datatools_workspacepath="$java_io_tmpdir/workspace_dtp"

# JAVA version >= 17
JAVACMD='java';
$JAVACMD -Djava.awt.headless=true -cp "$BIRTCLASSPATH" -DBIRT_HOME="$BIRT_HOME" -Dorg.eclipse.datatools_workspacepath="$org_eclipse_datatools_workspacepath" org.eclipse.birt.report.engine.api.ReportRunner ${1+"$@"}
mkdir -p "$java_io_tmpdir"
mkdir -p "$org_eclipse_datatools_workspacepath"

# Set BIRT class path
BIRTCLASSPATH="$THIS_DIR/lib/*"

# Set Java command
JAVACMD="java"

# Execute the command
echo "Java command=$JAVACMD -cp \"$BIRTCLASSPATH\" -Djava.awt.headless=true -DBIRT_HOME=$BIRT_HOME org.eclipse.birt.report.engine.api.ReportRunner $@"
$JAVACMD -cp "$BIRTCLASSPATH" -DBIRT_HOME="$BIRT_HOME" org.eclipse.birt.report.engine.api.ReportRunner "$@"
}

# Handle arguments
if [[ -z "$1" || ( "$1" == "--help" && -z "$2" ) ]]; then
usage
exit 0
else
run "$@"
fi

exit 0

Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@ related data source.

Running the BIRT Engine in Console
----------------------------------
In order to run the BIRT engine in command you should:
In order to run the BIRT engine in the command line shell you should:

1. set BIRT_HOME to the directory where BIRT Report Runtime Package is extracted.
2. enter into $BIRT_HOME/ReportEngine folder.
3. generate the report by running
genReport xxx.rptdesign
3 Here xxx.rptdesign is the design file. if the design file is in the current directory, you have to specify it by ./xxx.rptdesign
1. unzip de example zipfile
2. navigate to the ReportEngine folder.
3. see the generation instructions by running
genReport


License
-------
The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public
License Version 1.0 ("EPL"). A copy of the EPL is available at https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html.
License Version 2.0 ("EPL"). A copy of the EPL is available at https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html.
For purposes of the EPL, "Program" will mean the Content.

Redistributed Content
Expand Down

0 comments on commit ce5ac95

Please sign in to comment.