Skip to content

Commit

Permalink
refactor: rename to exhort
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
  • Loading branch information
ruromero committed Jul 19, 2023
1 parent 5fc7504 commit 40c34d4
Show file tree
Hide file tree
Showing 34 changed files with 235 additions and 194 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
blank_issues_enabled: false
contact_links:
- name: GitHub Discussions
url: https://github.com/RHEcosystemAppEng/crda-java-api/discussions/
url: https://github.com/RHEcosystemAppEng/exhort-java-api/discussions/
about: You can also use Discussions for questions and ideas.
4 changes: 2 additions & 2 deletions .github/workflows/oapi_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:

- name: Download OpenAPI spec
run: >
wget https://raw.githubusercontent.com/RHEcosystemAppEng/crda-backend/main/src/main/resources/META-INF/openapi.yaml
-O src/main/resources/crda_backend/openapi.yaml
wget https://raw.githubusercontent.com/RHEcosystemAppEng/exhort/main/src/main/resources/META-INF/openapi.yaml
-O src/main/resources/exhort/openapi.yaml
- name: Verify nothing was changed
run: git diff -s --exit-code
2 changes: 1 addition & 1 deletion .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Deploy snapshot to GitHub
if: |
contains(steps.project.outputs.version, 'SNAPSHOT') &&
github.repository == 'RHEcosystemAppEng/crda-java-api'
github.repository == 'RHEcosystemAppEng/exhort-java-api'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn deploy -Pprepare-deployment,deploy-github -B -ff
Expand Down
36 changes: 18 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to *crda-java-api*<br/>![java-version][10]
# Contributing to *exhort-java-api*<br/>![java-version][10]

* Fork the repository
* Create a new branch
Expand Down Expand Up @@ -37,16 +37,16 @@

### Good to know

* You can override the default backend url by setting another one in the _CRDA_BACKEND_URL_ environment variable.
* You can override the default backend url by setting another one in the _EXHORT_URL_ environment variable.

### OpenAPI Specifications

We use our [Backend's OpenAPI spec file][1] for generating types used for deserialization of the Backend's
API responses.<br/>
The generated classes target package is the `com.redhat.crda.backend`. It is skipped when calculating coverage
The generated classes target package is the `com.redhat.exhort.api`. It is skipped when calculating coverage
thresholds. **Avoid writing code in this package.**<br/>
When the [Backend's spec file][1] is modified, we need to **manually** copy it here in
[src/main/resources/crda_backend](src/main/resources/crda_backend/openapi.yaml),
[src/main/resources/exhort](src/main/resources/exhort/openapi.yaml),
for the *openapi-generator-maven-plugin* to pick it up at **build time**.

### Modular (JPMS)
Expand All @@ -59,23 +59,23 @@ This module is also being tested in a *modular* environment. Use

### Code Walkthrough

* The [CrdaApi](src/main/java/com/redhat/crda/impl/CrdaApi.java) is the *Crda Service*. It implements the
[Api](src/main/java/com/redhat/crda/Api.java) interface and provide various methods for requesting analysis reports.
* The [providers](src/main/java/com/redhat/crda/providers) are concrete implementations of the
[Provider](src/main/java/com/redhat/crda/Provider.java) interface. And are in charge of providing content and a
* The [ExhortApi](src/main/java/com/redhat/exhort/impl/ExhortApi.java) is the *Exhort Service*. It implements the
[Api](src/main/java/com/redhat/exhort/Api.java) interface and provide various methods for requesting analysis reports.
* The [providers](src/main/java/com/redhat/exhort/providers) are concrete implementations of the
[Provider](src/main/java/com/redhat/exhort/Provider.java) interface. And are in charge of providing content and a
content type to be encapsulated in the request to the Backend. At the time of writing this, we only have one
implementation, the [JavaMavenProvider](src/main/java/com/redhat/crda/providers/JavaMavenProvider.java)
implementation, the [JavaMavenProvider](src/main/java/com/redhat/exhort/providers/JavaMavenProvider.java)
implementation.
* The [tools](src/main/java/com/redhat/crda/tools) package hosts various utility tools and functions used throughout
the project. Tools such as the [Ecosystem](src/main/java/com/redhat/crda/tools/Ecosystem.java) for instantiating
providers per manifest. And the [Operations](src/main/java/com/redhat/crda/tools/Operations.java) for executing
* The [tools](src/main/java/com/redhat/exhort/tools) package hosts various utility tools and functions used throughout
the project. Tools such as the [Ecosystem](src/main/java/com/redhat/exhort/tools/Ecosystem.java) for instantiating
providers per manifest. And the [Operations](src/main/java/com/redhat/exhort/tools/Operations.java) for executing
process on the operating system.

#### Adding a Provider

* Create a concrete implementation of the [Provider](src/main/java/com/redhat/crda/Provider.java) abstraction and place
it in the [providers](src/main/java/com/redhat/crda/providers) package.
* In the [Ecosystem](src/main/java/com/redhat/crda/tools/Ecosystem.java) class look for the *getProvider function*
* Create a concrete implementation of the [Provider](src/main/java/com/redhat/exhort/Provider.java) abstraction and place
it in the [providers](src/main/java/com/redhat/exhort/providers) package.
* In the [Ecosystem](src/main/java/com/redhat/exhort/tools/Ecosystem.java) class look for the *getProvider function*
and add a *switch case* instantiating the new provider per file type.

### Integration Tests
Expand All @@ -93,10 +93,10 @@ $ mvn clean verify -Pits,dev
```

Integration tests are executed against a mocked _Backend_ server.<br/>
If you need to run against the actual _Backend_ server, use the _CRDA_ITS_USE_REAL_API_ environment variable:
If you need to run against the actual _Backend_ server, use the _EXHORT_ITS_USE_REAL_API_ environment variable:

```shell
CRDA_ITS_USE_REAL_API=true mvn clean verify -Pits
EXHORT_ITS_USE_REAL_API=true mvn clean verify -Pits
```

> TIP: When working on a new integration test project, it's helpful opening the IDE directly in the test project folder.
Expand All @@ -110,7 +110,7 @@ contribution. See the [DCO](DCO) file for details.

<!-- Real links -->
[0]: https://www.conventionalcommits.org/en/v1.0.0/
[1]: https://github.com/RHEcosystemAppEng/crda-backend/blob/main/src/main/resources/META-INF/openapi.yaml
[1]: https://github.com/RHEcosystemAppEng/exhort/blob/main/src/main/resources/META-INF/openapi.yaml

<!-- Badge links -->
[10]: https://badgen.net/badge/Java%20Version/11/5382a1
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# CodeReady Dependency Analytics Java API<br/>![latest-no-snapshot][0] ![latest-snapshot][1]

* Looking for our JavaScript/TypeScript API? Try [Crda JavaScript API](https://github.com/RHEcosystemAppEng/crda-javascript-api).
* Looking for our Backend implementation? Try [Crda Backend](https://github.com/RHEcosystemAppEng/crda-backend).
* Looking for our JavaScript/TypeScript API? Try [Exhort JavaScript API](https://github.com/RHEcosystemAppEng/exhort-javascript-api).
* Looking for our Backend implementation? Try [Exhort](https://github.com/RHEcosystemAppEng/exhort).

The _Crda Java API_ module is deployed to _GitHub Package Registry_.
The _Exhort Java API_ module is deployed to _GitHub Package Registry_.

<details>
<summary>Click here for configuring <em>GHPR</em> registry access.</summary>
Expand Down Expand Up @@ -69,7 +69,7 @@ encrypted-token-will-appear-here
...
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/RHEcosystemAppEng/crda-java-api</url>
<url>https://maven.pkg.github.com/RHEcosystemAppEng/exhort-java-api</url>
</repository>
...
</repositories>
Expand All @@ -83,7 +83,7 @@ encrypted-token-will-appear-here
repositories {
...
maven {
url 'https://maven.pkg.github.com/RHEcosystemAppEng/crda-java-api'
url 'https://maven.pkg.github.com/RHEcosystemAppEng/exhort-java-api'
credentials {
username System.getenv("GITHUB_USERNAME")
password System.getenv("GITHUB_TOKEN")
Expand All @@ -102,9 +102,9 @@ repositories {

```xml
<dependency>
<groupId>com.redhat.crda</groupId>
<artifactId>crda-java-api</artifactId>
<version>${crda-java-api.version}</version>
<groupId>com.redhat.exhort</groupId>
<artifactId>exhort-java-api</artifactId>
<version>${exhort-java-api.version}</version>
</dependency>
```
</li>
Expand All @@ -113,7 +113,7 @@ repositories {
<em>Gradle</em> users, add a dependency in <em>build.gradle</em>

```groovy
implementation 'com.redhat.crda:crda-java-api:${crda-java-api.version}'
implementation 'com.redhat.exhort:exhort-java-api:${exhort-java-api.version}'
```
</li>
</ul>
Expand All @@ -124,7 +124,7 @@ If working with modules, configure module read

```java
module x { // module-info.java
requires com.redhat.crda;
requires com.redhat.exhort;
}
```
</li>
Expand All @@ -133,26 +133,26 @@ module x { // module-info.java
Code example

```java
import com.redhat.crda.impl.CrdaApi;
import com.redhat.crda.backend.AnalysisReport;
import com.redhat.exhort.impl.ExhortApi;
import com.redhat.exhort.AnalysisReport;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.CompletableFuture;

public class CrdaExample {
public class ExhortExample {
public static void main(String... args) throws Exception {
// instantiate the Crda API implementation
var crdaApi = new CrdaApi();
// instantiate the Exhort API implementation
var exhortApi = new ExhortApi();

// get a byte array future holding a html Stack Analysis report
CompletableFuture<byte[]> htmlStackReport = crdaApi.stackAnalysisHtml("/path/to/pom.xml");
CompletableFuture<byte[]> htmlStackReport = exhortApi.stackAnalysisHtml("/path/to/pom.xml");

// get a AnalysisReport future holding a deserialized Stack Analysis report
CompletableFuture<AnalysisReport> stackReport = crdaApi.stackAnalysis("/path/to/pom.xml");
CompletableFuture<AnalysisReport> stackReport = exhortApi.stackAnalysis("/path/to/pom.xml");

// get a AnalysisReport future holding a deserialized Component Analysis report
var manifestContent = Files.readAllBytes(Paths.get("/path/to/pom.xml"));
CompletableFuture<AnalysisReport> componentReport = crdaApi.componentAnalysis("pom.xml", manifestContent);
CompletableFuture<AnalysisReport> componentReport = exhortApi.componentAnalysis("pom.xml", manifestContent);
}
}
```
Expand All @@ -174,7 +174,7 @@ Excluding a package from any analysis can be achieved by marking the package for
<em>Java Maven</em> users can add a comment in <em>pom.xml</em>

```xml
<dependency> <!--crdaignore-->
<dependency> <!--exhortignore-->
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
Expand All @@ -186,12 +186,12 @@ Excluding a package from any analysis can be achieved by marking the package for

<h3>Customization</h3>
<p>
There are 2 approaches for customizing <em>Crda Java API</em>. Using <em>Environment Variables</em> or
There are 2 approaches for customizing <em>Exhort Java API</em>. Using <em>Environment Variables</em> or
<em>Java Properties</em>:

```java
System.setProperty("CRDA_SNYK_TOKEN", "my-private-snyk-token");
System.setProperty("CRDA_MVN_PATH", "/path/to/custom/mvn");
System.setProperty("EXHORT_SNYK_TOKEN", "my-private-snyk-token");
System.setProperty("EXHORT_MVN_PATH", "/path/to/custom/mvn");
```

> Environment variables takes precedence.
Expand All @@ -210,7 +210,7 @@ can use the following keys for setting various vendor tokens.
</tr>
<tr>
<td><a href="https://app.snyk.io/redhat/snyk-token">Snyk</a></td>
<td>CRDA_SNYK_TOKEN</td>
<td>EXHORT_SNYK_TOKEN</td>
</tr>
</table>

Expand All @@ -230,10 +230,10 @@ following keys for setting custom paths for the said executables.
<tr>
<td><a href="https://maven.apache.org/">Maven</a></td>
<td><em>mvn</em></td>
<td>CRDA_MVN_PATH</td>
<td>EXHORT_MVN_PATH</td>
</tr>
</table>

<!-- Badge links -->
[0]: https://img.shields.io/github/v/release/RHEcosystemAppEng/crda-java-api?color=green&label=latest
[1]: https://img.shields.io/github/v/release/RHEcosystemAppEng/crda-java-api?color=yellow&include_prereleases&label=snapshot
[0]: https://img.shields.io/github/v/release/RHEcosystemAppEng/exhort-java-api?color=green&label=latest
[1]: https://img.shields.io/github/v/release/RHEcosystemAppEng/exhort-java-api?color=yellow&include_prereleases&label=snapshot
34 changes: 17 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.redhat.crda</groupId>
<artifactId>crda-java-api</artifactId>
<groupId>com.redhat.exhort</groupId>
<artifactId>exhort-java-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Crda Java API</name>
<description>Code-Ready Dependency Analytics Java API.</description>
<url>https://github.com/RHEcosystemAppEng/crda-java-api#readme</url>
<name>Exhort Java API</name>
<description>Exhort Java API</description>
<url>https://github.com/RHEcosystemAppEng/exhort-java-api#readme</url>
<inceptionYear>2023</inceptionYear>

<properties>
Expand Down Expand Up @@ -71,19 +71,19 @@

<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/RHEcosystemAppEng/crda-java-api/issues</url>
<url>https://github.com/RHEcosystemAppEng/exhort-java-api/issues</url>
</issueManagement>

<scm>
<url>https://github.com/RHEcosystemAppEng/crda-java-api</url>
<connection>scm:git:git@github.com:RHEcosystemAppEng/crda-java-api.git</connection>
<developerConnection>scm:git:git@github.com:RHEcosystemAppEng/crda-java-api.git</developerConnection>
<url>https://github.com/RHEcosystemAppEng/exhort-java-api</url>
<connection>scm:git:git@github.com:RHEcosystemAppEng/exhort-java-api.git</connection>
<developerConnection>scm:git:git@github.com:RHEcosystemAppEng/exhort-java-api.git</developerConnection>
<tag>HEAD</tag>
</scm>

<ciManagement>
<system>GitHub Workflows</system>
<url>https://github.com/RHEcosystemAppEng/crda-java-api/actions</url>
<url>https://github.com/RHEcosystemAppEng/exhort-java-api/actions</url>
</ciManagement>

<dependencyManagement>
Expand Down Expand Up @@ -350,7 +350,7 @@ limitations under the License.]]>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<excludes>
<exclude>com/redhat/crda/backend/*</exclude>
<exclude>com/redhat/exhort/api/*</exclude>
</excludes>
<propertyName>jacoco.java.option</propertyName>
<rules>
Expand Down Expand Up @@ -383,7 +383,7 @@ limitations under the License.]]>
<configuration>
<exportLineCoverage>true</exportLineCoverage>
<excludedClasses>
<excludedClass>com.redhat.crda.backend.*</excludedClass>
<excludedClass>com.redhat.exhort.api.*</excludedClass>
</excludedClasses>
<mutationThreshold>${mutation.coverage.threshold}</mutationThreshold>
<mutators>
Expand Down Expand Up @@ -527,7 +527,7 @@ limitations under the License.]]>
</executions>
</plugin>

<!-- openapi-generator-maven-plugin:generate is bound to the generate-sources phase and will generate sources from crda_backend spec -->
<!-- openapi-generator-maven-plugin:generate is bound to the generate-sources phase and will generate sources from exhort spec -->
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
Expand All @@ -537,9 +537,9 @@ limitations under the License.]]>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/crda_backend/openapi.yaml</inputSpec>
<inputSpec>${project.basedir}/src/main/resources/exhort/openapi.yaml</inputSpec>
<generatorName>java</generatorName>
<modelPackage>com.redhat.crda.backend</modelPackage>
<modelPackage>com.redhat.exhort.api</modelPackage>
<output>${project.build.directory}</output>
<configOptions>
<documentationProvider>none</documentationProvider>
Expand Down Expand Up @@ -674,11 +674,11 @@ limitations under the License.]]>
<distributionManagement>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/RHEcosystemAppEng/crda-java-api</url>
<url>https://maven.pkg.github.com/RHEcosystemAppEng/exhort-java-api</url>
</repository>
<snapshotRepository>
<id>github</id>
<url>https://maven.pkg.github.com/RHEcosystemAppEng/crda-java-api</url>
<url>https://maven.pkg.github.com/RHEcosystemAppEng/exhort-java-api</url>
</snapshotRepository>
</distributionManagement>
</profile>
Expand Down
10 changes: 5 additions & 5 deletions src/it/simple-modular/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.redhat.crda.integration.tests</groupId>
<artifactId>crda-java-api-simple-modular-it</artifactId>
<groupId>com.redhat.exhort.integration.tests</groupId>
<artifactId>exhort-java-api-simple-modular-it</artifactId>
<version>0.0.1</version>
<name>crda-java-api-simple-modular-it</name>
<name>exhort-java-api-simple-modular-it</name>

<properties>
<maven.compiler.release>11</maven.compiler.release>
Expand All @@ -17,8 +17,8 @@

<dependencies>
<dependency>
<groupId>com.redhat.crda</groupId>
<artifactId>crda-java-api</artifactId>
<groupId>com.redhat.exhort</groupId>
<artifactId>exhort-java-api</artifactId>
<version>@project.version@</version>
</dependency>
<dependency>
Expand Down
12 changes: 6 additions & 6 deletions src/it/simple-modular/src/test/java/module-info.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
jdk.attach,org.assertj.core,org.mockito,net.bytebuddy,net.bytebuddy.agent

--add-reads
com.redhat.crda.simple.modular.it=com.fasterxml.jackson.databind
com.redhat.exhort.simple.modular.it=com.fasterxml.jackson.databind
--add-reads
com.redhat.crda.simple.modular.it=org.assertj.core
com.redhat.exhort.simple.modular.it=org.assertj.core
--add-reads
com.redhat.crda.simple.modular.it=org.mockito
com.redhat.exhort.simple.modular.it=org.mockito
--add-reads
com.redhat.crda.simple.modular.it=java.net.http
com.redhat.exhort.simple.modular.it=java.net.http

--add-opens
com.redhat.crda.simple.modular.it/simple.modular=org.junit.platform.commons
com.redhat.exhort.simple.modular.it/simple.modular=org.junit.platform.commons
--add-opens
com.redhat.crda/com.redhat.crda.impl=com.redhat.crda.simple.modular.it
com.redhat.exhort/com.redhat.exhort.impl=com.redhat.exhort.simple.modular.it
Loading

0 comments on commit 40c34d4

Please sign in to comment.