Skip to content

Commit 8a9b237

Browse files
committed
Use jQAssistant YAML configuration file
1 parent 57c988d commit 8a9b237

File tree

4 files changed

+462
-12
lines changed

4 files changed

+462
-12
lines changed

scripts/resetAndScan.sh

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
JQASSISTANT_CLI_VERSION=${JQASSISTANT_CLI_VERSION:-"1.12.2"} # Version 1.12.2 is the current version (april 2023)
99
JQASSISTANT_CLI_ARTIFACT=${JQASSISTANT_CLI_ARTIFACT:-"jqassistant-commandline-neo4jv3"} # Neo4j v5: "jqassistant-commandline-distribution", Neo4j v4: "jqassistant-commandline-neo4jv3"
10+
JQASSISTANT_CONFIG_TEMPLATE=${JQASSISTANT_CONFIG_TEMPLATE:-"template-neo4jv5-jqassistant.yaml"} # Neo4j v5: "template-neo4jv5-jqassistant.yaml", Neo4j v4: "template-neo4jv4-jqassistant.yaml"
1011

1112
NEO4J_EDITION=${NEO4J_EDITION:-"community"} # Choose "community" or "enterprise"
1213
NEO4J_VERSION=${NEO4J_VERSION:-"4.4.20"} # Version 4.4.x is the current long term support (LTS) version (april 2023)
@@ -16,34 +17,53 @@ NEO4J_USER=${NEO4J_USER:-"neo4j"}
1617
ARTIFACTS_DIRECTORY=${ARTIFACTS_DIRECTORY:-"artifacts"} # Directory with the Java artifacts to scan and analyze
1718
TOOLS_DIRECTORY=${TOOLS_DIRECTORY:-"tools"} # Get the tools directory (defaults to "tools")
1819

20+
## Get this "scripts" directory if not already set
21+
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
22+
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
23+
# This way non-standard tools like readlink aren't needed.
24+
SCRIPTS_DIR=${SCRIPTS_DIR:-$( CDPATH=. cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P )}
25+
echo "resetAndScan: SCRIPTS_DIR=${SCRIPTS_DIR}"
26+
1927
# Internal constants
20-
JQASSISTANT_BIN="${TOOLS_DIRECTORY}/${JQASSISTANT_CLI_ARTIFACT}-${JQASSISTANT_CLI_VERSION}/bin"
21-
JQASSISTANT_NEO4J_OPTIONS="-storeUri ${NEO4J_BOLT_URI} -storeUsername ${NEO4J_USER} -storePassword ${NEO4J_INITIAL_PASSWORD}"
28+
JQASSISTANT_DIRECTORY="${TOOLS_DIRECTORY}/${JQASSISTANT_CLI_ARTIFACT}-${JQASSISTANT_CLI_VERSION}"
29+
JQASSISTANT_CONFIG="${JQASSISTANT_DIRECTORY}/config"
30+
JQASSISTANT_BIN="${JQASSISTANT_DIRECTORY}/bin"
31+
#JQASSISTANT_NEO4J_OPTIONS="-storeUri ${NEO4J_BOLT_URI} -storeUsername ${NEO4J_USER} -storePassword ${NEO4J_INITIAL_PASSWORD}"
32+
#JQASSISTANT_NEO4J_OPTIONS="-D jqassistant.store.uri=${NEO4J_BOLT_URI} -D jqassistant.store.remote.username=${NEO4J_USER} -D jqassistant.store.remote.password=${NEO4J_INITIAL_PASSWORD}"
33+
JQASSISTANT_NEO4J_OPTIONS="-configurationLocations ${JQASSISTANT_CONFIG}"
2234

2335
# Check if environment variable is set
2436
if [ -z "${NEO4J_INITIAL_PASSWORD}" ]; then
25-
echo "Requires environment variable NEO4J_INITIAL_PASSWORD to be set first. Use 'export NEO4J_INITIAL_PASSWORD=<your password'."
37+
echo "resetAndScan: Error: Requires environment variable NEO4J_INITIAL_PASSWORD to be set first. Use 'export NEO4J_INITIAL_PASSWORD=<your password'."
2638
exit 1
2739
fi
2840

2941
# Check if TOOLS_DIRECTORY variable is set
3042
if [ -z "${TOOLS_DIRECTORY}" ]; then
31-
echo "Requires variable TOOLS_DIRECTORY to be set. If it is the current directory, then use a dot to reflect that."
43+
echo "resetAndScan: Error: Requires variable TOOLS_DIRECTORY to be set. If it is the current directory, then use a dot to reflect that."
3244
exit 1
3345
fi
3446

3547
# Check if jQAssistant is installed
3648
if [ ! -d "${JQASSISTANT_BIN}" ] ; then
37-
echo "${JQASSISTANT_BIN} doesnt exist. Please run setupJQAssistant first."
49+
echo "resetAndScan: Error: ${JQASSISTANT_BIN} doesnt exist. Please run setupJQAssistant first."
3850
exit 1
3951
else
40-
echo "Using jQAssistant binary directory ${JQASSISTANT_BIN}"
52+
echo "resetAndScan: Using jQAssistant binary directory ${JQASSISTANT_BIN}"
4153
fi
4254

55+
# Create jQAssistant configuration YAML file by copying a template for it
56+
mkdir -p "${JQASSISTANT_CONFIG}" || exit 1
57+
cp "${SCRIPTS_DIR}/templates/${JQASSISTANT_CONFIG_TEMPLATE}" "${JQASSISTANT_CONFIG}/.jqassistant.yaml" || exit 1
58+
4359
# Use jQAssistant to scan the downloaded artifacts and write the results into the separate, local Neo4j Graph Database
44-
"${JQASSISTANT_BIN}"/jqassistant.sh scan ${JQASSISTANT_NEO4J_OPTIONS} -reset -f ./${ARTIFACTS_DIRECTORY}
60+
echo "resetAndScan: Analyzing ${ARTIFACTS_DIRECTORY} with jQAssistant CLI version ${JQASSISTANT_CLI_VERSION}"
61+
62+
#"${JQASSISTANT_BIN}"/jqassistant.sh scan ${JQASSISTANT_NEO4J_OPTIONS} -reset -f ./${ARTIFACTS_DIRECTORY}
63+
"${JQASSISTANT_BIN}"/jqassistant.sh scan ${JQASSISTANT_NEO4J_OPTIONS} -f ./${ARTIFACTS_DIRECTORY} || exit 1
4564

4665
# Use jQAssistant to add dependencies between artifacts, package dependencies, artifact dependencies and the java version to the Neo4j Graph Database
47-
"${JQASSISTANT_BIN}"/jqassistant.sh analyze ${JQASSISTANT_NEO4J_OPTIONS} \
48-
-reportDirectory ./runtime/jqassistant/report \
49-
-concepts classpath:Resolve,dependency:Package,dependency:Artifact,java:JavaVersion
66+
# "${JQASSISTANT_BIN}"/jqassistant.sh analyze ${JQASSISTANT_NEO4J_OPTIONS} \
67+
# -reportDirectory ./runtime/jqassistant/report \
68+
# -concepts classpath:Resolve,dependency:Package,dependency:Artifact,java:JavaVersion
69+
"${JQASSISTANT_BIN}"/jqassistant.sh analyze ${JQASSISTANT_NEO4J_OPTIONS}

scripts/setupJQAssistant.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SHARED_DOWNLOADS_DIRECTORY="${SHARED_DOWNLOADS_DIRECTORY:-$(dirname "$( pwd )")/
1414

1515
# Check if TOOLS_DIRECTORY variable is set
1616
if [ -z "${TOOLS_DIRECTORY}" ]; then
17-
echo "setupJQAssistant: Requires variable TOOLS_DIRECTORY to be set. If it is the current directory, then use a dot to reflect that."
17+
echo "setupJQAssistant: Error: Requires variable TOOLS_DIRECTORY to be set. If it is the current directory, then use a dot to reflect that."
1818
exit 1
1919
else
2020
# Create tools directory if it doesn't exists
@@ -24,7 +24,7 @@ fi
2424

2525
# Check if SHARED_DOWNLOADS_DIRECTORY variable is set
2626
if [ -z "${SHARED_DOWNLOADS_DIRECTORY}" ]; then
27-
echo "setupJQAssistant: Requires variable SHARED_DOWNLOADS_DIRECTORY to be set. If it is the current directory, then use a dot to reflect that."
27+
echo "setupJQAssistant: Error: Requires variable SHARED_DOWNLOADS_DIRECTORY to be set. If it is the current directory, then use a dot to reflect that."
2828
exit 1
2929
else
3030
# Create shared downloads directory if it doesn't exists
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
jqassistant:
2+
# Controls whether the execution of jQAssistant shall be skipped
3+
#
4+
# -Djqassistant.skip: true|false
5+
skip: false
6+
7+
# Defines the local and remote Maven repositories for retrieving additional plugins.
8+
repositories:
9+
# The path to the local repository.
10+
#
11+
# -Djqassistant.repositories.local (optional)
12+
local: ./../downloads/jqassistant-repository
13+
14+
# The list of plugins to load and activate.
15+
#
16+
# Each plugin is identified using its Maven coordinates:
17+
#
18+
# -Djqassistant.plugins[0].group-id
19+
# -Djqassistant.plugins[0].artifact-id
20+
# -Djqassistant.plugins[0].version
21+
# -Djqassistant.plugins[0].classifier (optional)
22+
# -Djqassistant.plugins[0].type (optional)
23+
#plugins:
24+
# - group-id:
25+
# artifact-id:
26+
# version:
27+
# classifier:
28+
# type:
29+
30+
# The store configuration
31+
store:
32+
# URI of the database to connect to. Supported URI schemes are 'file' for embedded databases and 'bolt' for connecting to a running Neo4j instance (3.x+), e.g.
33+
#
34+
# -Djqassistant.store.uri
35+
#uri: file://target/jqassistant/store
36+
uri: bolt://localhost:${NEO4J_BOLT_PORT:7687}
37+
38+
# Settings for the embedded Neo4j store
39+
embedded:
40+
# Enable the HTTP and BOLT connector for the embedded store
41+
#
42+
# -Djqassistant.store.embedded.connector-enabled: true|false
43+
connector-enabled: false
44+
45+
# The listen address for the HTTP and BOLT connectors
46+
#
47+
# -Djqassistant.store.embedded.listen-address
48+
listen-address: localhost
49+
50+
# The BOLT connector port
51+
#
52+
# -Djqassistant.store.embedded.bolt-port
53+
bolt-port: 7687
54+
55+
# The HTTP connector port
56+
#
57+
# -Djqassistant.store.embedded.http-port: 7474
58+
http-port: 7474
59+
60+
# Settings for connecting to a remote Neo4j store
61+
remote:
62+
# The user name for authentication.
63+
#
64+
# -Djqassistant.store.username
65+
username: ${NEO4J_USER:neo4j}
66+
67+
# The password for authentication.
68+
#
69+
# -Djqassistant.store.password
70+
password: ${NEO4J_INITIAL_PASSWORD}
71+
72+
# Activate encryption level for 'bolt' connections.
73+
#
74+
# -Djqassistant.store.encryption: true|false
75+
encryption: false
76+
77+
#The trust strategy for 'bolt' connections
78+
#
79+
# -Djqassistant.store.trust-strategy: trustAllCertificates|trustCustomCaSignedCertificates|trustSystemCaSignedCertificates
80+
trust-strategy: trustAllCertificates
81+
82+
# The file containing the custom CA certificate for trust strategy.
83+
#
84+
# -Djqassistant.store.trust-certificate
85+
trust-certificate:
86+
87+
# Additional properties to be passed to the remote store as key-value pairs.
88+
#
89+
# -Djqassistant.store.properties
90+
properties:
91+
92+
# The Scanner configuration
93+
scan:
94+
# Indicates whether to initially reset the store (i.e. clear all nodes and relationships) before scanning.
95+
#
96+
# -Djqassistant.scan.reset: true|false
97+
reset: true
98+
99+
# Specifies if a scan shall be continued if an error is encountered.
100+
#
101+
# -Djqassistant.scan.continue-on-error: true|false
102+
continue-on-error: false
103+
104+
# The items to include for scanning.
105+
include:
106+
# A list of files to include.
107+
#
108+
#jqassistant.scan.include.files[0]
109+
files:
110+
# - src/folder
111+
112+
# A list of URLs to include.
113+
#
114+
#jqassistant.scan.include.urls[0]
115+
urls:
116+
# - maven:repository::https://nexus/repository
117+
118+
# The properties to configure scanner plugins as key-value pairs. The supported properties are plugin specific.
119+
#
120+
# -Djqassistant.scan.properties
121+
properties:
122+
# plugin.property.key: value
123+
124+
# The analyze configuration
125+
analyze:
126+
# The rule configuration
127+
rule:
128+
# The name of the directory containing project rules.
129+
#
130+
# -Djqassistant.analyze.rule.directory
131+
directory: jqassistant/rules
132+
133+
# The default severity of concepts without an explicit severity.
134+
#
135+
# -Djqassistant.analyze.rule.default-concept-severity: INFO|MINOR|MAJOR|CRITICAL|BLOCKER
136+
default-concept-severity: MINOR
137+
138+
# The default severity of constraint without an explicit severity.
139+
#
140+
# -Djqassistant.analyze.rule.default-constraint-severity: INFO|MINOR|MAJOR|CRITICAL|BLOCKER
141+
default-constraint-severity: MAJOR
142+
143+
# The default severity of groups without an explicit severity.
144+
#
145+
# -Djqassistant.analyze.rule.default-group-severity: INFO|MINOR|MAJOR|CRITICAL|BLOCKER
146+
default-group-severity:
147+
148+
# The report configuration
149+
report:
150+
# The properties to configure report plugins. The supported properties are plugin specific.
151+
#
152+
# -Djqassistant.analyze.report.properties
153+
properties:
154+
# plugin.property.key: value
155+
156+
# Determines the severity level for reporting a warning.
157+
#
158+
# -Djqassistant.analyze.report.warn-on-severity: INFO|MINOR|MAJOR|CRITICAL|BLOCKER|NEVER
159+
warn-on-severity: MINOR
160+
161+
# Determines the severity level for reporting a failure.
162+
#
163+
# -Djqassistant.analyze.report.fail-on-severity: INFO|MINOR|MAJOR|CRITICAL|BLOCKER|NEVER
164+
fail-on-severity: MAJOR
165+
166+
# Determines if jQAssistant shall continue the build if failures have been detected.
167+
#
168+
# -Djqassistant.analyze.report.continue-on-failure: true|false
169+
continue-on-failure: false
170+
171+
# Create an archive containing all generated reports.
172+
#
173+
# -Djqassistant.analyze.report.create-archive: true|false
174+
create-archive: false
175+
176+
# Output directory for analysis reports
177+
directory: ./runtime/jqassistant/report
178+
179+
# The concepts to be applied.
180+
#
181+
# -Djqassistant.analyze.concepts[0]
182+
# Migration to v2: https://github.com/jQAssistant/jqa-java-plugin/blob/master/src/main/asciidoc/release-notes.adoc
183+
concepts:
184+
- classpath:Resolve
185+
- dependency:Package
186+
- dependency:Artifact
187+
- java:JavaVersion
188+
189+
# The constraints to be validated.
190+
#
191+
# -Djqassistant.analyze.constraints[0]
192+
constraints:
193+
# - my-constraint
194+
195+
# The groups to be executed.
196+
#
197+
# -Djqassistant.analyze.groups[0]
198+
groups:
199+
# - spring-boot:Default
200+
201+
# The parameters to be passed to the executed rules.
202+
#
203+
# -Djqassistant.analyze.rule-parameters."parameterName"
204+
rule-parameters:
205+
# parameterName: value
206+
207+
# Execute concepts even if they have already been applied before
208+
#
209+
# -Djqassistant.analyze.execute-applied-concepts: true|false
210+
execute-applied-concepts: false
211+
212+
# The execution time [seconds] for rules (concepts/constraints) to show a warning. Can be used as a hint for optimization.
213+
#
214+
# -Djqassistant.analyze.warn-on-rule-execution-time-seconds
215+
warn-on-rule-execution-time-seconds: 5

0 commit comments

Comments
 (0)