Skip to content

Commit

Permalink
migration to Nexus 3.71 API (#158)
Browse files Browse the repository at this point in the history
* update explicit Maven plugin versions

* update NXRM version to 3.70.1 and allow Java 11

* test: replace deprecated JUnit assertThat calls Hamcrest

* test: replace deprecated ExpectedException rule with assertThrows()

* test: replace deprecated JsonParser construction

* test: replace deprecated TempBlob usage

* replace deprecated markAsDownloaded() with default parameters

* add browse module

* add DAOs to store data with H2/Postgres backends

* update dependencies to Nexus 3.71.0

* add DAOs to store data with H2/Postgres backends

* return 404 for provider/package JSON of component does not exist

We re-generate the JSON on demand if it does not exist. But if the
requested package does not have any artifact, we should return 404
and not an empty response.

* implement lists for hosted repository

* move hosted, proxy and group classes into separate packages

* migrate recipes and handlers to fluent API

* move recipes and interfaces to separate packages

* docs: update README and user documentation

* add Java 17
* add notice for NXRM 3.71+
* update plugin version in examples
* update dead or outdated links

* ci: build with java 17

* test: fix integration tests

* test: migrate integration tests to new API

* test: add unit test for rewritePackageJson()
  • Loading branch information
stklcode authored Sep 13, 2024
1 parent a5af2eb commit 90f4a25
Show file tree
Hide file tree
Showing 67 changed files with 2,373 additions and 1,796 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
maven: circleci/[email protected].0
maven: circleci/[email protected].1
circleci-maven-release-orb: sonatype-nexus-community/[email protected]

release-args: &release-args
Expand All @@ -15,7 +15,7 @@ release-args: &release-args
jobs:
build_and_test:
docker:
- image: 'cimg/openjdk:8.0'
- image: 'cimg/openjdk:17.0'
steps:
- checkout
- maven/with_cache:
Expand Down
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Sonatype Nexus (TM) Open Source Version
Copyright (c) 2018-present Sonatype, Inc.
All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
All rights reserved. Includes the third-party code listed at https://www.sonatype.com/usage/attributions.
This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
which accompanies this distribution and is available at https://www.eclipse.org/legal/epl/epl-v10.html.
Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
Expand Down Expand Up @@ -38,7 +38,7 @@
### Requirements

* [Apache Maven 3.3.3+](https://maven.apache.org/install.html)
* [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
* [Java 17](https://adoptium.net/de/temurin/releases/?version=17) (recommended, also compatible with [Java 11](https://adoptium.net/de/temurin/releases/?version=11) and [Java 8](https://adoptium.net/de/temurin/releases/?version=8))
* Network access to https://repository.sonatype.org/content/groups/sonatype-public-grid

Also, there is a good amount of information available at [Bundle Development](https://help.sonatype.com/display/NXRM3/Bundle+Development)
Expand Down Expand Up @@ -78,6 +78,10 @@ The application will now be available from your browser at http://localhost:8081

[We have detailed instructions on how to get started here!](docs/COMPOSER_USER_DOCUMENTATION.md)

> **_Nexus Repository Composer_ 0.1+ is only compatible with _Nexus Repository Manager_ 3.71 or later**
>
> Use 0.0.x for older NXRM installations.
## Installing the plugin

There are a range of options for installing the Composer plugin. You'll need to build it first, and
Expand Down Expand Up @@ -108,14 +112,14 @@ good installation path if you are just testing or doing development on the plugi

* Enable the NXRM console: edit `<nexus_dir>/bin/nexus.vmoptions` and change `karaf.startLocalConsole` to `true`.

More details here: [Bundle Development](https://help.sonatype.com/display/NXRM3/Bundle+Development+Overview)
More details here: [Bundle Development](https://help.sonatype.com/en/bundle-development.html)

* Run NXRM's console:
```
# sudo su - nexus
$ cd <nexus_dir>/bin
$ ./nexus run
> bundle:install file:///tmp/nexus-repository-composer-0.0.8.jar
> bundle:install file:///tmp/nexus-repository-composer-0.1.0.jar
> bundle:list
```
(look for org.sonatype.nexus.plugins:nexus-repository-composer ID, should be the last one)
Expand All @@ -127,7 +131,7 @@ good installation path if you are just testing or doing development on the plugi

For more permanent installs of the nexus-repository-composer plugin, follow these instructions:

* Copy the bundle (nexus-repository-composer-0.0.8.jar) into <nexus_dir>/deploy
* Copy the bundle (nexus-repository-composer-0.1.0.jar) into <nexus_dir>/deploy

This will cause the plugin to be loaded with each restart of Nexus Repository. As well, this folder is monitored
by Nexus Repository and the plugin should load within 60 seconds of being copied there if Nexus Repository
Expand All @@ -137,7 +141,7 @@ is running. You will still need to start the bundle using the karaf commands men

If you are trying to use the Composer plugin permanently, it likely makes more sense to do the following:

* Copy the bundle into `<nexus_dir>/system/org/sonatype/nexus/plugins/nexus-repository-composer/0.0.8/nexus-repository-composer-0.0.8.jar`
* Copy the bundle into `<nexus_dir>/system/org/sonatype/nexus/plugins/nexus-repository-composer/0.1.0/nexus-repository-composer-0.1.0.jar`
* Make the following additions marked with + to `<nexus_dir>/system/org/sonatype/nexus/assemblies/nexus-core-feature/3.x.y/nexus-core-feature-3.x.y-features.xml`

```
Expand All @@ -148,9 +152,9 @@ If you are trying to use the Composer plugin permanently, it likely makes more s

And
```
+ <feature name="nexus-repository-composer" description="org.sonatype.nexus.plugins:nexus-repository-composer" version="0.0.8">
+ <feature name="nexus-repository-composer" description="org.sonatype.nexus.plugins:nexus-repository-composer" version="0.1.0">
+ <details>org.sonatype.nexus.plugins:nexus-repository-composer</details>
+ <bundle>mvn:org.sonatype.nexus.plugins/nexus-repository-composer/0.0.8</bundle>
+ <bundle>mvn:org.sonatype.nexus.plugins/nexus-repository-composer/0.1.0</bundle>
+ </feature>
</features>
```
Expand Down Expand Up @@ -178,8 +182,8 @@ Have fun creating and using this plugin and the Nexus platform, we are glad to h
Looking to contribute to our code but need some help? There's a few ways to get information:

* Chat with us on [Gitter](https://gitter.im/sonatype/nexus-developers)
* Check out the [Nexus3](http://stackoverflow.com/questions/tagged/nexus3) tag on Stack Overflow
* Check out the [Nexus Repository User List](https://groups.google.com/a/glists.sonatype.com/forum/?hl=en#!forum/nexus-users)
* Check out the [Nexus3](https://stackoverflow.com/questions/tagged/nexus3) tag on Stack Overflow
* Check out the [Nexus Repository User List](https://groups.google.com/a/glists.sonatype.com/g/nexus-users)

## Composer Plugin
The composer plugin `elendev/nexus-composer-push` (https://github.com/Elendev/nexus-composer-push) provide a composer command to push to a Nexus Repository using this plugin.
8 changes: 4 additions & 4 deletions docs/COMPOSER_USER_DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Sonatype Nexus (TM) Open Source Version
Copyright (c) 2018-present Sonatype, Inc.
All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
All rights reserved. Includes the third-party code listed at https://www.sonatype.com/usage/attributions.
This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
which accompanies this distribution and is available at https://www.eclipse.org/legal/epl/epl-v10.html.
Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
Expand Down Expand Up @@ -34,7 +34,7 @@ if anyone is interested in collaborating._
The current spike implementation makes certain assumptions about the layout of the upstream repository and is only
intended for use with the main Composer repository at [https://packagist.org](https://packagist.org/).

To proxy a Composer repository, you simply create a new 'composer (proxy)' as documented in [Repository Management](https://help.sonatype.com/display/NXRM3/Configuration#Configuration-RepositoryManagement)
To proxy a Composer repository, you simply create a new 'composer (proxy)' as documented in [Repository Management](https://help.sonatype.com/en/nexus-repository-administration.html#Configuration-RepositoryManagement)
in detail. Minimal configuration steps are:

- Define 'Name'
Expand Down Expand Up @@ -88,7 +88,7 @@ By default, Composer will only allow HTTPS URLs. To allow non-SSL URLs you will
### Browsing Composer Repository Packages

You can browse Composer repositories in the user interface inspecting the components and assets and their details, as
described in [Browsing Repositories and Repository Groups](https://help.sonatype.com/display/NXRM3/Browsing+Repositories+and+Repository+Groups).
described in [Browsing Repositories and Repository Groups](https://help.sonatype.com/en/browsing-repositories-and-repository-groups.html).

### Publishing Composer Packages

Expand Down
163 changes: 109 additions & 54 deletions nexus-repository-composer-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<parent>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>composer-parent</artifactId>
<version>0.0.30-SNAPSHOT</version>
<version>0.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>nexus-repository-composer-it</artifactId>
Expand All @@ -20,26 +21,22 @@
<artifactId>nexus-pax-exam</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-features</artifactId>
<type>xml</type>
</dependency>
<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest-client</artifactId>
</dependency>
<!--
Pax-Exam test driver - end
-->

<!--
only needed due to testsupport reference to: org.sonatype.nexus.repository.maven.VersionPolicy
Allow tests access to these APIs/helpers
-->
<dependency>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-repository-maven</artifactId>
<scope>provided</scope>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus.testsuite</groupId>
<artifactId>nexus-repository-testsupport</artifactId>
Expand All @@ -50,66 +47,134 @@
<groupId>org.sonatype.nexus.testsuite</groupId>
<artifactId>nexus-repository-testsupport</artifactId>
<version>${nxrm-version}</version>
<type>xml</type>
<classifier>features</classifier>
<type>xml</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus.testsuite</groupId>
<artifactId>nexus-it-suite-data</artifactId>
<version>${nxrm-version}</version>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-bootstrap</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rapture</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-repository-content</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest-client</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest-jackson2</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-script</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-extdirect</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-test-common</artifactId>
</dependency>

<!--
Allow tests access to these plugins
-->

<dependency>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-repository-composer</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<!--
Distributions to be tested
-->

<dependency>
<groupId>org.sonatype.nexus.assemblies</groupId>
<artifactId>nexus-base-template</artifactId>
<version>${nxrm-version}</version>
<type>zip</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-repository-composer</artifactId>
<version>${project.version}</version>
<artifactId>nexus-blobstore-tasks</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus.testsuite</groupId>
<artifactId>nexus-it-suite-data</artifactId>
<version>${nxrm-version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!--
ensure runtime dependencies required by ITs are in the local .m2/repository
Allow use of 'versionAsInProject' in Pax-Exam configuration
-->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>get</goal>
</goals>
<configuration>
<groupId>org.sonatype.nexus.buildsupport</groupId>
<artifactId>nexus-buildsupport-it-deps</artifactId>
<version>${nxrm-version}</version>
<packaging>pom</packaging>
</configuration>
</execution>
</executions>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
</plugin>

<!--
Allow use of 'versionAsInProject' in Pax-Exam configuration
Pre-fetch all the bundles listed in pax-exam-features
-->
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
<version>1.3</version>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-depends-file</id>
<id>fetch-pax-exam-features</id>
<phase>generate-resources</phase>
<goals>
<goal>generate-depends-file</goal>
<goal>features-add-to-repository</goal>
</goals>
<configuration>
<descriptors>
<descriptor>file:${project.artifactMap(org.ops4j.pax.exam:pax-exam-features).file}</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -125,27 +190,17 @@
</goals>
<configuration>
<target>
<unzip src="${org.sonatype.nexus.testsuite:nexus-it-suite-data:jar}" dest="${project.build.directory}/it-resources">
<unzip src="${org.sonatype.nexus.testsuite:nexus-it-suite-data:jar}"
dest="${project.build.directory}/it-resources">
<patternset>
<exclude name="META-INF/**" />
<exclude name="META-INF/**"/>
</patternset>
</unzip>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 90f4a25

Please sign in to comment.