SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
805 stars 171 forks source link

How to resolve dependency to with RESTHeart Platform in order to develop a custom plugin #376

Closed shireefadel closed 4 years ago

shireefadel commented 4 years ago

RESTHeart Platform version 4.1.11 is the last version I am using right now, but it seems that it is missing from maven repository.

I have the following issue when I tried to create a new plugin following the steps in the documentation along with this version 4.1.11 not your latest officially released one on maven

Failed to read artifact descriptor for com.restheart:restheart-platform-core:jar:4.1.9: Could not find artifact com.softinstigate.restheart:restheart-platform:pom:4.1.11 in central (https://repo.maven.apache.org/maven2)

and this is for sure because 4.1.11 didn't uploaded yet to maven or jitpack

Downloading from jitpack.io: https://jitpack.io/com/softinstigate/restheart/restheart-platform/4.1.11/restheart-platform-4.1.11.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE

mkjsix commented 4 years ago

Hi @shireefadel

What we usually do when we want to create a derivative project from the platform is to create a multi-module maven project containing two submodules. Have a look at the below example:

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.acme</groupId>
    <artifactId>acme-restheart-platform</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>core</module>
        <module>security</module>
    </modules>

    <properties>
        <!-- System -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <checkstyle.file.path>checkstyle-checker.xml</checkstyle.file.path>
        <dependency.locations.enabled>false</dependency.locations.enabled>
        <!-- Runtime dependencies -->
        <restheart-platform-security>1.4.3</restheart-platform-security>
        <restheart-platform-core>4.1.9</restheart-platform-core>
    </properties>

    <organization>
        <name>SoftInstigate</name>
        <url>https://softinstigate.com</url>
    </organization>

    <repositories>
        <repository>
            <id>restheart-platform-release</id>
            <name>S3 Release Repository</name>
            <url>s3://maven.softinstigate.com/release</url>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.restheart</groupId>
                <artifactId>restheart-platform-security</artifactId>
                <version>${restheart-platform-security}</version>
            </dependency>
            <dependency>
                <groupId>com.restheart</groupId>
                <artifactId>restheart-platform-core</artifactId>
                <version>${restheart-platform-core}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <extensions>
            <extension>
                <groupId>org.springframework.build</groupId>
                <artifactId>aws-maven</artifactId>
                <version>5.0.0.RELEASE</version>
            </extension>
        </extensions>
        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
        <finalName>${project.artifactId}-${project.version}-nodeps</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.2.1</version>
                    <configuration>
                        <finalName>${project.artifactId}</finalName>
                        <createDependencyReducedPom>true</createDependencyReducedPom>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>META-INF/*.SF</exclude>
                                    <exclude>META-INF/*.DSA</exclude>
                                    <exclude>META-INF/*.RSA</exclude>
                                </excludes>
                            </filter>
                            <filter>
                                <!-- removing overlapping classes, defined also in guava -->
                                <artifact>com.google.guava:failureaccess</artifact>
                                <excludes>
                                    <exclude>com/google/common/util/concurrent/internal/InternalFutureFailureAccess.class</exclude>
                                    <exclude>com/google/common/util/concurrent/internal/InternalFutures.class</exclude>
                                </excludes>
                            </filter>
                        </filters>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <transformers>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                        <mainClass>${mainclass}</mainClass>
                                    </transformer>
                                </transformers>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.1.1</version>
                    <executions>
                        <execution>
                            <id>bin</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <id>bin</id>
                                <appendAssemblyId>false</appendAssemblyId>
                                <finalName>${project.artifactId}-${project.version}</finalName>
                                <descriptors>
                                    <descriptor>assembly.xml</descriptor>
                                </descriptors>
                                <attach>false</attach>
                                <tarLongFileMode>posix</tarLongFileMode>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.1.2</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <mainClass>${mainclass}</mainClass>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <debug>true</debug>
                        <!--<compilerArgument>-Xlint</compilerArgument>-->
                        <showDeprecation>true</showDeprecation>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.22.2</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>
shireefadel commented 4 years ago

Hello @mkjsix , I think there is misunderstanding here, the original issue is that I am currently using version number 4.1.11 which Andrea sent to me in issue number #372, but it seems that it's not the official one, when I build my derivative project, it fails because it couldn't find the pom which refers to estheart-platform:pom:4.1.11

ujibang commented 4 years ago

Hi @shireefadel

to add the platform as a dependency in your pom follow instructions at https://restheart.org/docs/develop/packaging/

RESTHeart Platform is a commercial software and it is not published on maven.

If you are developing a plugin you can also refer to org.restheart:restheart:4.1.7

(RESTHeart Platform 4.1.11 uses restheart OSS 4.1.7; it is a bit confusing but the version of restheart platform does not match with the version of restheart OSS)

shireefadel commented 4 years ago

please send me the url for the latest version in order to develop a plugin

ujibang commented 4 years ago

The latest version (currently 4.1.11) of RESTHeart Platform can be downloaded from https://download.restheart.com/restheart-platform-4.1.11.zip

shireefadel commented 4 years ago

okay, so what is the exact dependency should I use for both core and security,

this one causes an error `

com.restheart restheart-platform-core 4.1.9

`

Could not resolve dependencies for project org.controlllo.iot:controlllo-backend:jar:1.0: Failed to collect dependencies at com.restheart:restheart-platform-core:jar:4.1.9: Failed to read artifact descriptor for com.restheart:restheart-platform-core:jar:4.1.9: Could not find artifact com.softinstigate.restheart:restheart-platform:pom:4.1.11

shireefadel commented 4 years ago

this is part of the pom file in 4.1.11 `

com.restheart
<artifactId>restheart-platform-core</artifactId>
<version>4.1.9</version>
<packaging>jar</packaging>
<name>restheart-platform-core</name>
<description>RESTHeart Platform Core - API microservice for MongoDB.</description>
<url>http://www.restheart.org</url>
<inceptionYear>2019</inceptionYear>

``

com.softinstigate.restheart restheart-platform 4.1.11

`

ujibang commented 4 years ago

following instructions on https://restheart.org/docs/develop/packaging/#package-restheart-security-plugins

added restheart-platform-core.jar and restheart-platform-security.jar as a local Maven dependency

leads to error

mvn compile

Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact com.softinstigate.restheart:restheart-platform:pom:4.1.11 has not been downloaded from it before. -> [Help 1]

maybe because of the parent pom being refereed in restheart-platform-core and restheart-platform-security poms

mkjsix commented 4 years ago

Hi @shireefadel We are looking for a better solution for this. Please give us some time to put the right files in the right places. I'll keep you up to date.

mkjsix commented 4 years ago

@shireefadel do you mind writing us an email to info@softinstigate.com so that we can contact you directly?

shireefadel commented 4 years ago

Hi @shireefadel We are looking for a better solution for this. Please give us some time to put the right files in the right places. I'll keep you up to date.

Hello @mkjsix , I know it will take sometime, so I'd prefer permanent solution, so it's okay talk your time

ujibang commented 4 years ago

Hi @shireefadel

We are currently working hard on simplify the packaging of custom plugins and we are almost done!

Basically you'll just need to build a normal jar (with compile dependencies to RESTHeart and restheart-plugin OSS, where the plugin interfaces are all defined) and copy the jar into the plugin directory.

RESTHeart will pick them up at boot time!

Hope you'll like this!

ujibang commented 4 years ago

Hi all, we are releasing RESTHeart v5, at present it's RC2 (release candidate 2).

Work si not finished yet, but please have a look at the update introductory documentation on master branch and let us know: https://github.com/SoftInstigate/restheart/blob/master/README.md

mkjsix commented 4 years ago

@shireefadel we are gathering plugin examples for the upcoming v5 here: https://github.com/SoftInstigate/restheart-examples

ujibang commented 4 years ago

closing this for lack of activity. feel free to reopen if needed.