Skip to content

Commit 49a63bd

Browse files
committed
added CLI configuration options and cleaned up code
1 parent 232b7c2 commit 49a63bd

19 files changed

+450
-126
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
910
### Added
11+
1012
- Upcoming changes...
1113

14+
## [0.2.0] - 2023-07-04
1215

13-
## [0.0.1] - 2023-06-??
1416
### Added
15-
- ?
1617

17-
[0.0.1]: https://github.com/scanoss/scanoss.java/compare/v0.0.0...v0.0.1
18+
- First pass at the following Classes
19+
- Fingerprinting ([Winnowing](src/main/java/com/scanoss/Winnowing.java))
20+
- Scanning ([Scanner](src/main/java/com/scanoss/Scanner.java))
21+
- REST Interface ([ScanApi](src/main/java/com/scanoss/rest/ScanApi.java))
22+
- JSON Utils ([JsonUtils](src/main/java/com/scanoss/utils/JsonUtils.java))
23+
- CLI ([CommandLine](src/main/java/com/scanoss/cli/CommandLine.java))
24+
25+
[0.0.1]: https://github.com/scanoss/scanoss.java/compare/v0.0.0...v0.2.0

CONTRIBUTING.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Contributing
2-
Thank you for considering contributing to SCANOSS. It's people like you that make SCANOSS such a great tool. Feel welcome and read the following sections
2+
3+
Thank you for considering contributing to SCANOSS. It's people like you that make SCANOSS such a great tool. Feel
4+
welcome and read the following sections
35
in order to know how to get involved, ask questions and more importantly how to work on something.
46

5-
SCANOSS is an open source project, and we love to receive contributions from our community. There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests, or writing code.
7+
SCANOSS is an open source project, and we love to receive contributions from our community. There are many ways to
8+
contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature
9+
requests, or writing code.
610
A welcome addition to the project is an integration with a new source code repository.
711

812
### Submitting bugs
@@ -17,12 +21,18 @@ If you are submitting a bug, please tell us:
1721

1822
Want to submit a pull request? Great! But please follow some basic rules:
1923

20-
- Write a brief description that help us understand what you are trying to accomplish: what the change does, link to any relevant issue
21-
- If you are changing a source file please make sure that you only include in the changeset the lines changed by you (beware of your editor reformatting the file)
24+
- Write a brief description that help us understand what you are trying to accomplish: what the change does, link to any
25+
relevant issue
26+
- If you are changing a source file please make sure that you only include in the changeset the lines changed by you (
27+
beware of your editor reformatting the file)
2228
- If you are adding functionality, please write a unit test.
2329

2430
### Licensing
2531

26-
The SCANOSS Platform is released under the GPL-2.0 license. If you wish to contribute, you must accept that you are aware of the license under which the project is released, and that your contribution will be released under the same license.
27-
Sometimes the GPL-2.0 license is incompatible with other licenses chosen by other projects. Therefore, you must accept that your contribution can also be released under the MIT license, which is the license we choose for those situations.
28-
Unless you expressly request otherwise, we may use your name, email address, username or URL for your attribution notice text. The submission of your contribution implies that you agree with these licensing terms.
32+
The SCANOSS Platform is released under the GPL-2.0 license. If you wish to contribute, you must accept that you are
33+
aware of the license under which the project is released, and that your contribution will be released under the same
34+
license.
35+
Sometimes the GPL-2.0 license is incompatible with other licenses chosen by other projects. Therefore, you must accept
36+
that your contribution can also be released under the MIT license, which is the license we choose for those situations.
37+
Unless you expressly request otherwise, we may use your name, email address, username or URL for your attribution notice
38+
text. The submission of your contribution implies that you agree with these licensing terms.

README.md

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# SCANOSS Java Library
2-
The SCANOSS java package provides a simple, easy to consume library for interacting with SCANOSS APIs/Engine.
32

3+
The SCANOSS java package provides a simple, easy to consume library for interacting with SCANOSS APIs.
4+
5+
[![Unit Test](https://github.com/scanoss/scanoss.java/actions/workflows/java-ci.yml/badge.svg)](https://github.com/scanoss/scanoss.java/actions/workflows/java-ci.yml)
6+
[![Release](https://github.com/scanoss/scanoss.java/actions/workflows/release.yml/badge.svg)](https://github.com/scanoss/scanoss.java/actions/workflows/release.yml)
47

58
## Usage
6-
TBD
9+
10+
The latest version of the package can be found
11+
on [Maven Central](https://central.sonatype.com/artifact/com.scanoss/scanoss).
712

813
Include in a maven project using:
14+
915
```xml
1016
<dependency>
1117
<groupId>com.scanoss</groupId>
@@ -14,40 +20,107 @@ Include in a maven project using:
1420
</dependency>
1521
```
1622

23+
And in gradle using:
24+
25+
```
26+
implementation group: 'com.scanoss', name: 'scanoss', version: '0.1.3'
27+
```
28+
29+
Examples of consuming this SDK can be found in the [cli](src/main/java/com/scanoss/cli) package folder.
30+
Specifically, the [ScanCommandLine.java](src/main/java/com/scanoss/cli/ScanCommandLine.java) shows how to instantiate
31+
the `Scanner` class to initiate a scan.
32+
33+
Here is a simple way to initiate a scan using all the SCANOSS defaults:
34+
35+
```java
36+
import com.scanoss.Scanner;
37+
38+
public class Test {
39+
public static void main(String[] args) {
40+
Scanner scanner = Scanner.builder().build();
41+
String file = "test.java";
42+
String result = scanner.scanFile(file);
43+
}
44+
}
45+
```
46+
47+
### CLI
48+
49+
The package also ships with a sample CLI. It can be run using the example script [scanoss-cli.sh](scanoss-cli.sh):
50+
51+
```bash
52+
scanos-cli.sh -h
53+
```
54+
1755
## Development
18-
Before starting with development of this project, please read our [CONTRIBUTING](CONTRIBUTING.md) and [CODE OF CONDUCT](CODE_OF_CONDUCT.md).
56+
57+
Before starting with development of this project, please read our [CONTRIBUTING](CONTRIBUTING.md)
58+
and [CODE OF CONDUCT](CODE_OF_CONDUCT.md).
1959

2060
### Requirements
61+
2162
Java 11 or higher.
2263

2364
The dependencies can be found in the [pom.xml](pom.xml).
2465

66+
### Testing
67+
68+
A full set of [unit tests](src/test/java/com/scanoss) are included with the package.
69+
70+
To run tests, using the following command:
71+
72+
```bash
73+
make test
74+
```
75+
2576
### Package Development
2677

2778
#### Versioning
28-
The version of the package is defined in the [pom.xml](pom.xml) file. Please update this version before packaging/releasing an update.
79+
80+
The version of the package is defined in the [pom.xml](pom.xml) file. Please update this version before
81+
packaging/releasing an update.
82+
83+
The following commands are provided for incrementing version:
84+
85+
```bash
86+
make inc_path
87+
make inc_minor
88+
make inc_major
89+
```
2990

3091
#### Packaging
92+
3193
To package the library, please run:
94+
3295
```bash
33-
make dist
96+
make package
3497
```
3598

99+
#### Dependency Updates
100+
36101
Check for dependency updates:
102+
37103
```bash
38104
mvn versions:display-dependency-updates
39105
```
40106

41107
#### Deployment
42108

43109
Then deploy to prod:
110+
44111
```bash
45-
make publish
112+
make deploy
46113
```
47-
This will deploy the package to [Maven Central](https://maven.org/?).
114+
115+
This will deploy the package to [Maven Central](https://central.sonatype.com/artifact/com.scanoss/scanoss).
116+
117+
Alternatively pushing a tagged version to GitHub will trigger
118+
the [Release](https://github.com/scanoss/scanoss.java/actions/workflows/release.yml) Action to automate the deployment.
48119

49120
## Bugs/Features
121+
50122
To request features or alert about bugs, please do so [here](https://github.com/scanoss/scanoss.java/issues).
51123

52124
## Changelog
125+
53126
Details of major changes to the library can be found in [CHANGELOG.md](CHANGELOG.md).

pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>com.scanoss</groupId>
88
<artifactId>scanoss</artifactId>
9-
<version>0.1.4</version>
9+
<version>0.2.0</version>
1010
<packaging>jar</packaging>
1111
<name>scanoss.java</name>
1212
<url>https://github.com/scanoss/scanoss.java</url>
@@ -42,11 +42,11 @@
4242
</properties>
4343

4444
<distributionManagement>
45-
<!-- <repository>-->
46-
<!-- <id>github</id>-->
47-
<!-- <name>GitHub SCANOSS Apache Maven Packages</name>-->
48-
<!-- <url>https://maven.pkg.github.com/scanoss/scanoss.java</url>-->
49-
<!-- </repository>-->
45+
<!-- <repository>-->
46+
<!-- <id>github</id>-->
47+
<!-- <name>GitHub SCANOSS Apache Maven Packages</name>-->
48+
<!-- <url>https://maven.pkg.github.com/scanoss/scanoss.java</url>-->
49+
<!-- </repository>-->
5050
<snapshotRepository>
5151
<id>ossrh</id>
5252
<name>Maven Central Snapshot Repo</name>

scanoss-cli.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
##########################################
4+
#
5+
# Launch the SCANOSS CLI jar from this project area
6+
# The package has to be built before it can run
7+
#
8+
##########################################
9+
10+
b_dir=$(dirname "$0") # script location
11+
if [ "$b_dir" = "" ]; then
12+
b_dir=.
13+
fi
14+
export b_dir
15+
16+
# Search in the 'target' directory for the CLI jar file to execute
17+
jar_file=$(find "$b_dir/target" -name "scanoss*jar-with-dependencies.jar" -print | sort | tail -1)
18+
if [ "$jar_file" = "" ] ; then
19+
# Nothing there, so search the full subfolder tree
20+
jar_file=$(find "$b_dir" -name "scanoss*jar-with-dependencies.jar" -print | sort | tail -1)
21+
if [ "$jar_file" = "" ] ; then
22+
echo "ERROR: Failed to find SCANOSS jar file to run."
23+
exit 1
24+
fi
25+
fi
26+
export jar_file
27+
exec java -jar "$jar_file" "$@"

settings.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
<passphrase>${env.MAVEN_GPG_PASSPHRASE}</passphrase>
1111
</server>
1212
</servers>
13-
<!-- <profiles>-->
14-
<!-- <profile>-->
15-
<!-- <activation>-->
16-
<!-- <activeByDefault>true</activeByDefault>-->
17-
<!-- </activation>-->
18-
<!-- <properties>-->
19-
<!-- <gpg.keyname>${env.GPG_KEY}</gpg.keyname>-->
20-
<!-- <gpg.passphrase>${env.GPG_PWD}</gpg.passphrase>-->
21-
<!-- </properties>-->
22-
<!-- </profile>-->
23-
<!-- </profiles>-->
13+
<!-- <profiles>-->
14+
<!-- <profile>-->
15+
<!-- <activation>-->
16+
<!-- <activeByDefault>true</activeByDefault>-->
17+
<!-- </activation>-->
18+
<!-- <properties>-->
19+
<!-- <gpg.keyname>${env.GPG_KEY}</gpg.keyname>-->
20+
<!-- <gpg.passphrase>${env.GPG_PWD}</gpg.passphrase>-->
21+
<!-- </properties>-->
22+
<!-- </profile>-->
23+
<!-- </profiles>-->
2424
</settings>

0 commit comments

Comments
 (0)