Overview
Globalyzer Lite can be run as an external tool from Integrated Development Environments
(IDEs) such as Visual Studio, Eclipse, and IntelliJ IDEA. This provides a convenient way to
scan source code for i18n issues within a development environment.
Running Globalyzer Lite from within an IDE requires some initial setup. This tutorial covers setting up Globalyzer
Lite as an external tool from:
If you are using an IDE other than those listed, you may still be able to use Globalyzer
Lite. The general requirements for an IDE to support Globalyzer Lite are:
- The IDE must be able to create external tools.
- The IDE must be able to provide these tools with some basic
project information.
- Optionally, it is desirable for the IDE to automatically jump to files linked from within an output
console.
For basic project information, the IDE must
provide the project's location. Preferably, it should also specify which
file/directory is open or selected in the workspace. In Visual Studio,
Eclipse, and IntelliJ, this information is provided as variables/macros within
the external tool setup interface. The instructions for setup within each IDE are
similar, so you may use any of them as a guide for setting up Globalyzer Lite within a
different, unlisted IDE.
Globalyzer Lite requires using a Project Definition File. Running Globalyzer Lite can be done several ways
and the Project Definition File and system configuration changes slightly with each method.
- Locally. If Globalyzer Lite is run locally, the rulesets and the Globalyzer.license file must also reside on
the system.
- Remotely with the Globalyzer Server login in the Project Definition File. The Project Definition File must contain the username, password and server information to login into the Globalyzer Server and retrieve rulesets.
- Remotely, with the Globalyzer Server login information in a
.globalyzerrc file. This is used when the Project Definition File is shared. Each user's individual Globalyzer Server information is stored in a file on their system.
For more details and examples about Project Definition Files for use with an IDE,
see project definition file examples.
Place the project definition file in the lingoport directory in source directory of your project.
Visual Studio
Any recent version of Visual Studio can be used. For a demonstration of using Globalyzer Lite in
Visual Studio, see
this video .
Prerequisites
-
Before setting up Globalyzer Lite, make sure that you have Java installed. The default
Java install location is
C:\Program Files\Java . Browse there and
look for an installed jre or jdk. You can
also do java -version from a command prompt to verify that Java is
installed. And to check its version. Java 11 and above are supported.
> java -version
openjdk version "11.0.20" 2023-07-18
OpenJDK Runtime Environment (build 11.0.20+8)
OpenJDK 64-Bit Server VM (build 11.0.20+8, mixed mode)
> C:\Program Files\java\jre11.0.20\bin>
> dir java.exe
-
Extract the Globalyzer Lite compressed file. For the purpose of convention, we
recommend placing it under
C:\Lingoport\ folder on Windows. The
extraction will create a globalyzer-lite-x.y.z folder. Where x.y.z is the
current version.
-
Run the installation script from the command line. Open a command prompt. The
following commands assume that the package was extracted into the default directory.
> cd C:\Lingoport\globalyzer-lite-x.y.z\
> install-lite.bat
-
Create a Globalyzer Project Definition XML file or use one that has been given to you.
For this tutorial, the file's name
will be assumed to be
LiteProjectDefinition.xml . For
instructions on how to create one and more details about the Project Definition
file, see creating a project
definition file. For more details and examples about Project Definition Files for use with an IDE,
see project definition file examples.
Place the project definition file in the lingoport directory in source directory of your project.
-
Make non-project files viewable so that you will be able to see Globalyzer Lite's
reports after they are generated.
- In Visual Studio, in the Solution Explorer, select
the "Show All Files" button.
After scanning your code with Globalyzer Lite, the reports will be placed in a
specified output directory, as defined by the --report-path option.
For this
tutorial, it will be called "globalyzer-lite-reports". You do not need to create
this directory, it will be automatically generated when Globalyzer Lite successfully performs a
scan.
After generating some initial reports, you may make the generated reports part of your
solution. Report names are based off of a combination of the name of the scan they
represent and their report type. Note that if a scan is added to your project definition
file (or renamed within it), this will cause a new, differently named, report to be
generated. The new report may not be included in your solution, and thus will only
appear if you list non-solution files.
Setup Visual Studio
To begin, open the External Tool Configuration wizard (Tools ->
External Tools...). Click the Add button to configure a new external tool.
This tool is configured to scan the topmost file or directory currently selected in the
Solution Explorer. This tool will display the scan results in the output console.
- Title: GlobalyzerLite-ScanSelected
- Command:
C:\Program Files\Java\Your (jre|jdk) Version Here\bin\java.exe
- Arguments:
-jar "C:\Lingoport\globalyzer-lite-x.y.z\globalyzer-lite.jar" -f
lingoport/LiteProjectDefinition.xml
--project-path "$(SolutionDir)"
--scan-items "$(ItemPath)"
--console-output visual-studio
-
"-f": Name of the Project Definition XML file. It is recommended that
the Project Definition file be placed into the project source code base directory.
-
"--project-path": Specifies the path to this project. Optional, but
useful if a project definition file is being shared between users. Users
may store the project in different locations within their system.
- "--scan-items": Overrides the default settings for which files and
directories to scan (as defined in the project definition file).
- "$(ItemPath)": The absolute path to the resource selected in the
Solution Explorer.
- If multiple resources are selected, returns the path to
only the first one.
- Quotes are recommended, as the item path may contain spaces. Any
content after a space would otherwise be interpreted as an
additional argument.
- "--console-output": Print scan report output to console with specified
format.
-
"visual-studio": Format report output for visual studio.
This allows the user to click on a candidate issue in the output
and jump to its location within a file.
-
Note: The generated report is parsed to create this output.
Currently, only the report styles ScanDetailedXML and
ScanDetailedCSV are supported. You may set the report style in
the project definition file.
- Initial Directory:
$(ProjectDir)
-
Use Output window: Recommended.
Running Globalyzer Lite
To run Globalyzer Lite, go to the Tools menu. The Globalyzer Lite-based external tool
which you just configured will be present. Click on the tool to run it.
Be sure that you have finished configuring a project definition file.
Warning: If you have not selected a file or directory in the Solution
Explorer, the variables used in the external tools may be blank. This may cause
unexpected behavior (e.g. no scan items given due to blank $(ItemPath)).
Warning: Non-project must be viewable in Solution Explorer or you will not be able to see
the report output directory when it is created.
Here is some output after scanning a file:
In this example, the file "CircuitButton.cs"
was scanned using the GlobalyzerLite-ScanSelected task. The workspace is arranged so
that the file scanned, the scan output, and the scan results (as recorded in
csharpscan_detailed_report.csv) are all visible.
Note that the first issue found is the embedded string "Button" located on line
19 of the file. To jump directly from an issue in a report
to its location in the source code, double-click on the line in the console output.
Note also that "csharpscan_detailed_report.csv" and
"xmlscan_detailed_report.csv" are visible in the Solution Explorer. As
mentioned previously, these will not automatically be part of the current solution.
You will either need to set them as such (and add any additional scan reports as
they are created), or enable viewing of non-solution items.
Globalyzer Lite Task for VSCode
Prerequisites
-
Before setting up Globalyzer Lite, make sure that you have Java installed. The default
Java install location is
C:\Program Files\Java . Browse there and
look for an installed jre or jdk. You can
also do java -version from a command prompt to verify that Java is
installed. And to check its version. Java 11 and above are supported.
> java -version
openjdk version "11.0.20" 2023-07-18
OpenJDK Runtime Environment (build 11.0.20+8)
OpenJDK 64-Bit Server VM (build 11.0.20+8, mixed mode)
> C:\Program Files\java\jre11.0.20\bin>
> dir java.exe
-
Extract the Globalyzer Lite compressed file. For the purpose of convention, we
recommend placing it under
C:\Lingoport\ folder on Windows. The
extraction will create a globalyzer-lite-x.y.z folder. Where x.y.z is the
current version.
-
Run the installation script from the command line. Open a command prompt. The
following commands assume that the package was extracted into the default directory.
> cd C:\Lingoport\globalyzer-lite-x.y.z\
> install-lite.bat
-
Create a Globalyzer Project Definition XML file or use one that has been given to you.
For this tutorial, the file's name
will be assumed to be
LiteProjectDefinition.xml . For
instructions on how to create one and more details about the Project Definition
file, see creating a project
definition file. For more details and examples about Project Definition Files for use with an IDE,
see project definition file examples.
Place the project definition file in the lingoport directory in source directory of your project.
Configure Plugin
- Open your project folder in VSCode
- Select Terminal->Configure Tasks from the top menu bar
- Select Create tasks.json file from template from the popup option list
- Select Others from the Task Template list
- Change the default template for the generated tasks.json file to match the following
{
"version": "2.0.0",
"tasks": [
{
"label": "GlobalyzerLite",
"type": "shell",
"command": "java",
"args": [
{
"value": "-jar",
"quoting": "weak"
},
{
"value": "/Applications/Lingoport/globalyzer-lite-6.8.0_4.0/globalyzer-lite.jar",
"quoting": "strong"
},
{
"value": "-f",
"quoting": "weak"
},
{
"value": "${workspaceFolder}/lingoport/LiteProjectDefinition.xml",
"quoting": "strong"
},
{
"value": "--project-path",
"quoting": "weak"
},
{
"value": "${workspaceFolder}",
"quoting": "strong"
},
{
"value": "--report-path",
"quoting": "weak"
},
{
"value": "${workspaceFolder}/Lingoport",
"quoting": "strong"
},
{
"value": "--scan-items",
"quoting": "weak"
},
{
"value": "${file}",
"quoting": "strong"
},
{
"value": "--console-output",
"quoting": "weak"
},
{
"value": "visual-studio",
"quoting": "weak"
}
],
"presentation": {
"showReuseMessage": false,
"clear": true,
"revealProblems": "onProblem"
},
"problemMatcher": {
"fileLocation": ["absolute"],
"severity": "warning",
"owner": "globalyzer",
"pattern": {
"regexp": "^(.*)\\((\\d*)\\):\\s+(.*),\\s+(P\\d+):\\s+(.*)",
"file": 1,
"line": 2,
"message": 3,
"severity": 4,
"code": 5
}
}
}
]
}
- label is the name of the task - this can be changed to whatever makes the most sense
- type specifies that the command should be run in a shell - required
- command is the command to execute in the shell - required
- args specifies the arguments to be passed to the command at execution
- value contains the actual arguments
- -jar specifies the jar to execute
- Replace path/to/globalyzer-lite.jar with the absolute path to your globalyzer-lite.jar
- E.g. C:/Lingoport/globalyzer-lite-x.y.z/globalyzer-lite.jar
- -f is the name of the Project Definition file
- Replace the path/to/LiteProjectDefinition.xml with the workspace relative path of your Project Definition file
- E.g. ${workspaceFolder}/lingoport/LiteProjectDefinition.xml
- --project-path is the path of this project
- Leave this as the ${workspaceFolder} VSCode environment variable
- --scan-items Overrides the default settings for which files and directories to scan
- Use ${file} to scan only the currently selected file in VSCode
- --console-output prints scan report output to console with specified format
- Leave as "visual-studio" - format report output for visual studio. This allows the user to click on a candidate issue in the output and jump to its location within a file.
- quoting specifies how to handle quoting within the args - 'strong' is used for arguments that may contain spaces.
- presentation configures how the workspace should handle displaying the task as it executes
- problemMatcher uses a regular expression to extract the problems found in the scan and display them in the problems panel
To Execute a Scan on the Current Opened File
- Select Terminal->Run Task and choose the GlobalyzerLite task from the list in the modal window
- Scan will execute in a VSCode terminal panel and display problems in the problems panel if any are found
Eclipse
Version 4.4 or higher for Windows, OSX and Linux is recommended. For a demonstration of using Globalyzer Lite in
Eclipse, see
this video .
Prerequisites
Linux
-
Before setting up Globalyzer Lite in Eclipse, be sure that you have Java installed
and determine its location. Java 1.7 and above are supported.
> java -version
> which java
-
Extract the Globalyzer Lite compressed file. We recommend extracting from the home
directory. The extraction will create a
globalyzer-lite-x.y.z
directory. Where x.y.z is the version you are using.
> cd <home-directory>
> unzip globalyzer-lite-x.y.z.zip
-
Run the installation script. This only needs to be run at installation and not
again. The following commands assume that the package was extracted into the default
directory.
> cd <home-directory>/globalyzer-lite-x.y.z
> ./lite-setup.sh
-
By default, console clickability in Eclipse is limited to Java, and the
linked files must have been built in the workspace. Globalyzer Lite ships with an Eclipse
plugin, ClickableConsole, which will enable links to all files from the console.
Installing this plugin is highly recommended.
-
To install the plugin, copy "EclipseClickableConsolePlugin.jar" to:
<Eclipse install dir>/dropins/plugins
creating the plugins directory if necessary. The
plugin should be loaded the next time Eclipse is (re)started.
> mkdir <Eclipse installation>/dropins/plugins
> cp <home-directory>/globalyzer-lite-6.8.0/EclipseClickableConsolePlugin.jar <Eclipse installation>/dropins/plugins/
-
Restart Eclipse and verify that the plug-in is recognized by Eclipse by selecting Help
-> Installation Details and selecting the Plug-ins tab. Search for
"Clickable".
-
Create a Globalyzer Project Definition XML file or use one that has been given to you.
For this tutorial, the file's name
will be assumed to be
LiteProjectDefinition.xml . For
instructions on how to create one and more details about the Project Definition
file, see creating a project
definition file. For more details and examples about Project Definition Files for use with an IDE,
see project definition file examples.
Place the project definition file in the lingoport directory in source directory of your project.
OSX
-
Before setting up Globalyzer Lite in Eclipse, be sure that you have Java installed
and determine its location. Java 1.7 and above are supported.
> java -version
> which java
-
Extract the Globalyzer Lite compressed file. We recommend extracting into /Applications/Lingoport,
creating the directory if it does not already exist. The extraction will create a
globalyzer-lite-x.y.z
directory. Where x.y.z is the version you are using.
> sudo mkdir -p /Applications/Lingoport
> sudo chown '0755' /Applications/Lingoport
> unzip -d /Applications/Lingoport/ globalyzer-lite-x.y.z.zip
-
Run the installation script. This only needs to be run at installation and not
again. The following commands assume that the package was extracted into the default
directory.
> cd /Applications/Lingoport/globalyzer-lite-x.y.z
> ./lite-setup.sh
-
By default, console clickability in Eclipse is limited to Java, and the
linked files must have been built in the workspace. Globalyzer Lite ships with an Eclipse
plugin, ClickableConsole, which will enable links to all files from the console.
Installing this plugin is highly recommended.
-
To install the plugin, copy "EclipseClickableConsolePlugin.jar" to:
<Eclipse install dir>/dropins/plugins
creating the plugins directory if necessary. The
plugin should be loaded the next time Eclipse is (re)started.
> mkdir <Eclipse installation>/dropins/plugins
> cp /Applications/Lingoport/globalyzer-lite-6.8.0_x.y/EclipseClickableConsolePlugin.jar <Eclipse installation>/dropins/plugins/
-
Restart Eclipse and verify that the plug-in is recognized by Eclipse by selecting Help
-> Installation Details and selecting the Plug-ins tab. Search for
"Clickable".
-
Create a Globalyzer Project Definition XML file or use one that has been given to you.
For this tutorial, the file's name
will be assumed to be
LiteProjectDefinition.xml . For
instructions on how to create one and more details about the Project Definition
file, see creating a project
definition file. For more details and examples about Project Definition Files for use with an IDE,
see project definition file examples.
Place the project definition file in the lingoport directory in source directory of your project.
Windows
-
Before setting up Globalyzer Lite in Eclipse, make sure that you have Java installed.
The default Java install location is
C:\Program Files\Java .
Browse there and look for an installed jre or jdk. Java 1.7 and above are supported.
For this example, jdk1.7.0_40 was
used. You can also do java -version from a command prompt.
-
Extract the Globalyzer Lite compressed file. For the
purpose of convention, we recommend placing it under
C:\Lingoport\ . The compressed file will create
a globalyzer-lite-x.y.z folder. Where x.y.z is the version being used.
-
Run the installation script from the command line. Open a command prompt. The
following commands assume that the package was extracted into the default directory.
> cd C:\Lingoport\globalyzer-lite-x.y.z\
> install-lite.bat
-
By default, console clickability in Eclipse is limited to Java files, and the
linked files must have been built in the workspace. Globalyzer Lite ships with an Eclipse
plugin, ClickableConsole, which will enable links to all files from the console.
Installing this plugin is highly recommended.
-
To install the plugin, copy "EclipseClickableConsolePlugin.jar" to:
<Eclipse install dir>/dropins/plugins
creating the plugins directory if necessary. The
plugin should be loaded the next time Eclipse is (re)started.
> mkdir <Eclipse installation>\dropins\plugins
> copy <home-directory>\globalyzer-lite-x.y.z\EclipseClickableConsolePlugin.jar <Eclipse installation>\dropins\plugins\
-
Restart Eclipse and verify that the plug-in is recognized by Eclipse by selecting Help
-> About -> Installation Details and selecting the Plug-ins tab. Search for
"Clickable".
-
Create a Globalyzer Project Definition XML file or use one that has been given to you.
For this tutorial, the file's name
will be assumed to be
LiteProjectDefinition.xml . For
instructions on how to create one and more details about the Project Definition
file, see creating a project
definition file. For more details and examples about Project Definition Files for use with an IDE,
see project definition file examples.
Place the project definition file in the lingoport directory in source directory of your project.
Setup
Globalyzer Lite will be run as an external tool. The External Tool Configuration wizard
includes Eclipse set variables, such as ${project_loc} ,
${container_loc} and ${selected_resource_loc} , which can be
used to automatically specify files or directories for Globalyzer Lite to scan.
To use Globalyzer Lite, an external tool must be created. The tool will scan depending
on what has been selected in the Package Explorer. If the project is selected, the
entire project will be scanned. If a subdirectory is selected, all the directories and
files under that folder will be scanned. If a file is selected, only that file will be
scanned. This scan will execute the contents of your project definition file without
making any modifications. You may decide what a scan involves by creating a project definition file. The
project definition file allows you to login to the Globalyzer server and use defined
rule sets for scanning.
To start, open the External Tool Configuration wizard (Run -> External Tools ->
External Tools Configurations...). Click Program, then select the New button to create a
new tool.
- Name: GlobalyzerLite-ScanSelected
- Location: place the path to Java on your system.
- Windows:
C:\Program Files\Java\a (jre|jdk) version here\bin\java.exe
- Linux / OSX:
/usr/bin/java
- Or output of
`which java`
- Working Directory:
${project_loc}
- Arguments:
-jar "/Location of Globalyzer Lite on your system/globalyzer-lite-6.8.0/globalyzer-lite.jar" -f
lingoport\LiteProjectDefinition.xml
--project-path "${project_loc}"
--scan-items "${selected_resource_loc}"
--console-output gnu
- Windows:
-jar "C:\Lingoport\globalyzer-lite-x.y.z\globalyzer-lite.jar" -f
lingoport\LiteProjectDefinition.xml
--project-path "${project_loc}"
--scan-items "${selected_resource_loc}"
--console-output gnu
- Linux:
-jar "/home/username/globalyzer-lite-x.y.z/globalyzer-lite.jar" -f
lingoport/LiteProjectDefinition.xml
--project-path "${project_loc}"
--scan-items "${selected_resource_loc}"
--console-output gnu
- OSX:
-jar "/Applications/Lingoport/globalyzer-lite-x.y.z/globalyzer-lite.jar" -f
lingoport/LiteProjectDefinition.xml
--project-path "${project_loc}"
--scan-items "${selected_resource_loc}"
--console-output gnu
-
"-f": Name of the Project Definition XML file. It is recommended that
the Project Definition file is placed into the project source code base directory.
-
"--project-path": Specifies the path to this project. Optional, but
useful if a project definition file is being shared between users. Users
may store the project in different locations within their system.
- "--console-output": Print scan report output to console with specified
format.
-
Note: The generated report is parsed to create this
output. Currently, only the report styles ScanDetailedXML and
ScanDetailedCSV are supported in the Project Definition file.
- "eclipse-default": Format the report output for Eclipse. This will NOT
allow consistent jumping from console output to file locations. This does not require the ClickableConsole plug-in.
- "gnu": Format the report output so that the output will allow selection
of the filename in the console output to go to the file location. ClickableConsole requires this to be set.
- "${selected_resource_loc}": The absolute path to the resource selected
in the Package Explorer.
-
If multiple resources are selected, returns the path to only
the first one.
-
Quotes are recommended, as the item path may contain spaces. Any
content after a space would otherwise be interpreted as an
additional argument.
Running Globalyzer Lite
To run Globalyzer Lite, look for the tool you just created under Run ->
External Tools. Or under the Tools button.
Warning: If you have not selected a file or directory in the Package
Explorer, the variables used in the external tools may be blank. This will cause
unexpected behavior (e.g. no scan item given due to blank ${selected_resource_loc})
NOTE: You will need to refresh the Package Explorer in order to see the
'globalyzer-lite-reports' folder when it is first created.
After scanning your code with Globalyzer Lite, the reports will be placed in a
specified output directory, as defined by the
--report-path option. For this
tutorial, it will be called "globalyzer-lite-reports". You do not need to create
this directory, it will be automatically generated when Globalyzer Lite successfully
performs a scan.
Here is some output after a scanning a file:
In this example, the directory java/example-source-java was scanned using the
GlobalyzerLite-ScanSelected task. The workspace is arranged so that the directory scanned,
the scan output, and the scan results (as recorded in javascan_detailed_report.csv) are in the
globalyzer-lite-reports directory
are all visible. The console links are in the "gnu" format.
IntelliJ IDEA or Android Studio
For a demonstration of using Globalyzer Lite in IntelliJ IDEA see
this video .
Prerequisites
Linux
-
Before setting up Globalyzer Lite in IntelliJ IDEA or Android Studio, be sure that you have Java
installed and determine its location.
> java -version
> which java
-
Extract the Globalyzer Lite compressed file. We recommend placing it under the home
directory on Linux. The extraction will create a
globalyzer-lite-x.y.z directory.
> cd <home-directory>
> unzip globalyzer-lite-x.y.z.zip
-
Run the installation script. This only needs to be run at installation and not
again. The following commands assume that it was extracted into the home directory.
> cd <home-directory>/globalyzer-lite-x.y.z
> ./lite-setup.sh
-
Create a Globalyzer Project Definition XML file or use one that has been given to you.
For this tutorial, the file's name
will be assumed to be
LiteProjectDefinition.xml . For
instructions on how to create one and more details about the Project Definition
file, see creating a project
definition file. For more details and examples about Project Definition Files for use with an IDE,
see project definition file examples.
Place the project definition file in the lingoport directory in source directory of your project.
OSX
-
Before setting up Globalyzer Lite in IntelliJ IDEA or Android Studio, be sure that you have Java
installed and determine its location.
> java -version
> which java
-
Extract the Globalyzer Lite compressed file. We recommend extracting into /Applications/Lingoport,
creating the directory if it does not already exist. The extraction will create a
globalyzer-lite-x.y.z
directory. Where x.y.z is the version you are using.
> sudo mkdir -p /Applications/Lingoport
> sudo chown '0755' /Applications/Lingoport
> unzip -d /Applications/Lingoport/ globalyzer-lite-x.y.z.zip
-
Run the installation script. This only needs to be run at installation and not
again. The following commands assume that it was extracted into the home directory.
> cd /Applications/Lingoport/globalyzer-lite-x.y.z
> ./lite-setup.sh
-
Create a Globalyzer Project Definition XML file or use one that has been given to you.
For this tutorial, the file's name
will be assumed to be
LiteProjectDefinition.xml . For
instructions on how to create one and more details about the Project Definition
file, see creating a project
definition file. For more details and examples about Project Definition Files for use with an IDE,
see project definition file examples.
Place the project definition file in the lingoport directory in source directory of your project.
Windows
-
Before setting up Globalyzer Lite in IntelliJ IDEA or Android Studio, be sure that you have Java
installed. The default Java install location is
C:\Program Files\Java . Browse there and look for an installed jre or jdk. For this
example, jdk1.7.0_40 was used. You can also do
java -version from a command prompt.
-
Extract the Globalyzer Lite compressed file. For the purpose of convention, we
recommend placing it under
C:\Lingoport\ folder on Windows.The
compressed file will create a globalyzer-lite-x.y.z folder.
-
Run the installation script from the command line. Open a command prompt. The
following commands assume that the package was extracted into the default directory.
> cd C:\Lingoport\globalyzer-lite-x.y.z\
> install-lite.bat
-
Create a Globalyzer Project Definition XML file or use one that has been given to you.
For this tutorial, the file's name
will be assumed to be
LiteProjectDefinition.xml . For
instructions on how to create one and more details about the Project Definition
file, see creating a project
definition file. For more details and examples about Project Definition Files for use with an IDE,
see project definition file examples.
Place the project definition file in the lingoport directory in source directory of your project.
After scanning your code with Globalyzer Lite, the reports will be placed in a specified
output directory, as defined by the
--report-path option. For this tutorial, it will
be called "globalyzer-lite-reports". You do not need to create this directory, it will
be automatically generated when Globalyzer Lite successfully performs a scan.
Setup
Globalyzer Lite will be run as an external tool. The External Tools Configuration wizard
includes IDEA set variables (macros), such as $ProjectFileDir$ ,
$FilePathRelativeToProjectRoot$ and $FileRelativeDir$ , which
can be used to automatically specify files or directories for Globalyzer Lite to scan.
To use Globalyzer Lite, an external tool must be created. The tool will scan the
item selected in the Project Explorer. If the project is selected, the
entire project will be scanned. If a subdirectory is selected, all the directories and
files under that folder will be scanned. If a file is selected, only that file will be
scanned. If nothing is (actively) selected, IntelliJ will pass empty input for the
--scan-items. Unusual results may occur including scanning an open file.
This scan will execute the contents of your project definition file. You may decide what
a scan involves by creating a project
definition file. The project definition file allows you to login to the Globalyzer
server and use predefined rule sets for scanning.
Note that both the project path and scan-items given in the project definition file will
be overridden by those specified by the tool. No modifications will be made to the project
definition file itself.
To begin, creating the tool open the external tool configuration wizard (File ->
Settings...). Select Tools and External Tools. Click the Add (+) button to create a new tool.
This tool is configured to scan whatever file or directory is currently selected in the
Solution Explorer. This tool will display the scan results in the output console.
- Name: GlobalyzerLite-ScanSelected
-
Description: Scan the currently open/selected file or folder with Globalyzer Lite
- Program: place the path to Java on your system.
- Windows:
C:\Program Files\Java\a (jre|jdk) version here\bin\java.exe
- Linux / OSX:
/usr/bin/java
- Or output of
`which java`
- Parameters:
-jar "/Location of Globalyzer Lite on your system/globalyzer-lite-x.y.z/globalyzer-lite.jar"
-f lingoport/LiteProjectDefinition.xml --project-path "$ProjectFileDir$"
--scan-items "$FilePathRelativeToProjectRoot$"
--console-output gnu
- Windows:
-jar "C:\Lingoport\globalyzer-lite-x.y.z\globalyzer-lite.jar"
-f lingoport\LiteProjectDefinition.xml
--project-path "$ProjectFileDir$"
--scan-items "$FilePathRelativeToProjectRoot$"
--console-output gnu
- Linux:
-jar "/home/username/globalyzer-lite-x.y.z/globalyzer-lite.jar"
-f lingoport/LiteProjectDefinition.xml
--project-path "$ProjectFileDir$"
--scan-items "$FilePathRelativeToProjectRoot$"
--console-output gnu
- OSX:
-jar "/Applications/Lingoport/globalyzer-lite-x.y.z/globalyzer-lite.jar"
-f lingoport/LiteProjectDefinition.xml
--project-path "$ProjectFileDir$"
--scan-items "$FilePathRelativeToProjectRoot$"
--console-output gnu
-
"-f": Name of the Project Definition XML file. It is recommended that
the Project Definition file is placed into the project source code base directory.
-
"--project-path": Specifies the path to this project. Optional, but
useful if a project definition file is being shared between users. Users
may store the project in different locations within their system.
-
"$ProjectFileDir$": The path to this solutions project file. Should
reflect the base directory of the solution.
-
"--scan-items": Overrides the default settings for which files and
directories to scan (as defined in the project definition file).
-
"$FilePathRelativeToProjectRoot$": The project relative path to the
resource that is either open or selected in the project explorer.
-
If multiple resources are selected, returns the path to only
the top one.
-
Quotes are recommended, as the path may contain spaces. Any
content after a space would otherwise be interpreted as an
additional argument.
-
"--console-output": Print scan report output to console with specified
format.
-
"gnu": Format report output for IntelliJ IDEs. Will allow jumping from
formatted output to locations in the file.
-
Note: The generated report is parsed to create this output.
Currently, only the report styles ScanDetailedXML and
ScanDetailedCSV in the Project Definition file are supported.
- Working Directory:
$ProjectFileDir$
You must also create an output filter (See button on the middle-right) in order to
enable jumping the console report output directly to the relevant file and line.
- "Output Filters...": Enable jumping directly to issues from console output.
-
"Name:" Jump To Line
-
"Description:" Jump to specified line in given file
-
"Regular expression to match output:" $FILE_PATH$:$LINE$
Running Globalyzer Lite
To run Globalyzer Lite, look for the tool you just created under Tools
-> External Tools. .Click on the tool to run it. Be sure that you have finished
configuring a project definition file.
Warning: If you do not have a file within your project either open or selected,
the macro $FilePathRelativeToProjectRoot$ will be blank. Your tools will not know where
to look to find any of the files within your project.
Here is some output after a scanning a file:
In this example, the file "WorldWindCatalogs.java" was scanned using the
GlobalyzerLite-ScanSelected task. The workspace is arranged so that the file
scanned, the scan output, and the scan results (as recorded in
JavaBasicScan_detailed_report.csv) are all visible.
|