forked from metaschema-framework/oscal-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilding.md.vm
More file actions
195 lines (126 loc) · 3.44 KB
/
building.md.vm
File metadata and controls
195 lines (126 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Building from Source
This guide explains how to build the OSCAL CLI from source code.
## Prerequisites
| Requirement | Minimum Version | Notes |
|:------------|:----------------|:------|
| Java JDK | 17 | Required for building (output JARs are JDK 11 compatible) |
| Maven | 3.9.0 | Required for building |
| Git | 2.0 | Required for cloning |
Ensure `JAVA_HOME` is set correctly:
```bash
# macOS
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
# Linux (adjust path to your installation)
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
# Windows
set JAVA_HOME=C:\Program Files\Java\jdk-17
```
## Clone the Repository
Clone the repository with submodules:
```bash
git clone --recurse-submodules https://github.com/metaschema-framework/oscal-cli.git
cd oscal-cli
```
If you already cloned without submodules, initialize them:
```bash
git submodule update --init --recursive
```
## Build Commands
### Basic Build
Build and install to your local Maven repository:
```bash
mvn install
```
This produces the CLI distribution in `target/oscal-cli-enhanced-*-oscal-cli.zip`.
### Run Tests Only
```bash
mvn test
```
### Run a Single Test
```bash
# Run a single test class
mvn test -Dtest=CLITest
# Run a single test method
mvn test -Dtest=CLITest#testValidate
```
### Skip Tests
```bash
mvn install -DskipTests
```
### CI/CD Build
Replicate the full CI/CD build (recommended before pushing):
```bash
mvn install -PCI -Prelease
```
This enables additional checks including:
- License header verification
- Checkstyle code style checks
- SpotBugs static analysis
- Full test suite
## Code Quality Commands
### Check License Headers
```bash
mvn license:check
```
### Auto-format Source Code
```bash
mvn formatter:format
```
### Check for Checkstyle Issues
```bash
mvn checkstyle:check
```
## Running the Built CLI
After building, you can run the CLI directly:
```bash
# Extract the distribution
unzip target/oscal-cli-enhanced-*-oscal-cli.zip -d target/cli
# Run the CLI
target/cli/bin/oscal-cli --help
```
## Building Container Images
To build a local container image:
```bash
# Build with Docker
docker build -t oscal-cli:local .
# Test the image
docker run --rm oscal-cli:local --help
```
## Building the Site
To build the project documentation site:
```bash
mvn site
```
The generated site appears in `target/site/`.
## Common Build Issues
### Submodule Not Initialized
**Symptom:** Build fails with missing OSCAL or Metaschema files.
**Solution:** Initialize submodules:
```bash
git submodule update --init --recursive
```
### Java Version Mismatch
**Symptom:** Compilation errors or "unsupported class file version" errors.
**Solution:** Ensure you're using Java 17 or later for building:
```bash
java -version
mvn -version
```
### Maven Version Too Old
**Symptom:** Build fails with plugin compatibility errors or enforcer rule failures.
**Solution:** Upgrade Maven to 3.9.0 or later:
```bash
mvn -version
```
### Out of Memory
**Symptom:** Build fails with `OutOfMemoryError`.
**Solution:** Increase Maven's heap size:
```bash
export MAVEN_OPTS="-Xmx2g"
mvn install
```
## Contributing
For contribution guidelines, including code style requirements and the pull request process, see [CONTRIBUTING.md](${project.scm.url}/blob/develop/CONTRIBUTING.md).
## Next Steps
- [Installation](installation.html) - Install the pre-built CLI
- [CLI Reference](guides/cli-reference.html) - Complete command reference