- 
                Notifications
    
You must be signed in to change notification settings  - Fork 11
 
Feature/create library project #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0fafa58
              0ad1ed6
              d3f3b85
              16e2466
              da77f82
              cb9634d
              d0d3afd
              3ea7585
              b6df8c3
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -9,34 +9,28 @@ plugins { | |
| id 'maven-publish' | ||
| } | ||
| 
     | 
||
| group = 'com.iexec.blockchain' | ||
| sourceCompatibility = 11 | ||
| targetCompatibility = 11 | ||
| 
     | 
||
| ext { | ||
| openFeignVersion = '11.6' | ||
| gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim() | ||
| } | ||
| 
     | 
||
| if (gitBranch != 'main' && gitBranch != 'master' && ! (gitBranch ==~ '(release|hotfix|support)/.*')) { | ||
| version += '-NEXT-SNAPSHOT' | ||
| } | ||
| 
     | 
||
| configurations { | ||
| compileOnly { | ||
| extendsFrom annotationProcessor | ||
| } | ||
| } | ||
| 
     | 
||
| repositories { | ||
| mavenLocal() | ||
| mavenCentral() | ||
| // iExec | ||
| maven { | ||
| url "https://nexus.iex.ec/repository/maven-public/" | ||
| allprojects { | ||
| group = 'com.iexec.blockchain' | ||
| sourceCompatibility = 11 | ||
| targetCompatibility = 11 | ||
| if (gitBranch != 'main' && gitBranch != 'master' && !(gitBranch ==~ '(release|hotfix|support)/.*')) { | ||
| version += '-NEXT-SNAPSHOT' | ||
| } | ||
| maven { | ||
| url "https://jitpack.io" | ||
| repositories { | ||
| mavenLocal() | ||
| mavenCentral() | ||
| // iExec | ||
| maven { | ||
| url "https://nexus.iex.ec/repository/maven-public/" | ||
| } | ||
| maven { | ||
| url "https://jitpack.io" | ||
| } | ||
| } | ||
| } | ||
| 
     | 
||
| 
          
            
          
           | 
    @@ -73,6 +67,9 @@ dependencies { | |
| implementation "io.github.openfeign:feign-core:$openFeignVersion" | ||
| implementation "io.github.openfeign:feign-jackson:$openFeignVersion" | ||
| implementation "io.github.openfeign:feign-slf4j:$openFeignVersion" | ||
| 
     | 
||
| // integration tests | ||
| implementation project(':iexec-blockchain-adapter-api-library') | ||
| } | ||
| 
     | 
||
| springBoot { | ||
| 
          
            
          
           | 
    @@ -156,6 +153,6 @@ ext.ociImageName = 'local/' + ['bash', '-c', 'basename $(git config --get remo | |
| task buildImage(type: Exec) { | ||
| group 'Build' | ||
| description 'Builds an OCI image from a Dockerfile.' | ||
| commandLine("sh", "-c", "docker build -f docker/Dockerfile-local --build-arg spring_boot_jar=$bootJarPath -t $ociImageName:$gitShortCommit ." | ||
| commandLine("sh", "-c", "docker build -f docker/Dockerfile --build-arg spring_boot_jar=$bootJarPath -t $ociImageName:$gitShortCommit ." | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No palantir docker extension anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was removed to converge between all repositories and to be able to quickly copy/paste the   | 
||
| + " && docker tag $ociImageName:$gitShortCommit $ociImageName:dev") | ||
| } | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,23 +1,10 @@ | ||
| ARG HOME=/home | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍  | 
||
| ARG spring_boot_jar | ||
| # Build app container | ||
| FROM openjdk:11.0.3-jre-slim | ||
| 
     | 
||
| # Build jar | ||
| FROM gradle:6.8.3-jdk11 as gradle-builder | ||
| ARG HOME | ||
| WORKDIR $HOME | ||
| ARG spring_boot_jar | ||
| 
     | 
||
| RUN test -n "$spring_boot_jar" | ||
| COPY build.gradle gradle.properties settings.gradle ./ | ||
| COPY src/ src/ | ||
| RUN gradle build -i --no-daemon | ||
| 
     | 
||
| # Build app container | ||
| FROM openjdk:11.0.3-jre-slim | ||
| ARG HOME | ||
| ARG spring_boot_jar | ||
| COPY --from=gradle-builder $HOME/$spring_boot_jar app.jar | ||
| ENTRYPOINT [ "/bin/sh", "-c", "exec java -Djava.security.egd=file:/dev/./urandom -jar app.jar" ] | ||
| COPY $spring_boot_jar app.jar | ||
| 
     | 
||
| # CI/CD version | ||
| ## git clone, then cd into | ||
| ## docker image build -f docker/Dockerfile . | ||
| ENTRYPOINT [ "/bin/sh", "-c", "exec java -Djava.security.egd=file:/dev/./urandom -jar app.jar" ] | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ARG HOME=/home | ||
| ARG spring_boot_jar | ||
| 
     | 
||
| # Build jar | ||
| FROM gradle:6.8.3-jdk11 as gradle-builder | ||
| ARG HOME | ||
| WORKDIR $HOME | ||
| ARG spring_boot_jar | ||
| RUN test -n "$spring_boot_jar" | ||
| COPY build.gradle gradle.properties settings.gradle ./ | ||
| COPY src/ src/ | ||
| RUN gradle build -i --no-daemon | ||
| 
     | 
||
| # Build app container | ||
| FROM openjdk:11.0.3-jre-slim | ||
| ARG HOME | ||
| ARG spring_boot_jar | ||
| COPY --from=gradle-builder $HOME/$spring_boot_jar app.jar | ||
| ENTRYPOINT [ "/bin/sh", "-c", "exec java -Djava.security.egd=file:/dev/./urandom -jar app.jar" ] | ||
| 
     | 
||
| # CI/CD version | ||
| ## git clone, then cd into | ||
| ## docker image build -f docker/Dockerfile . | 
This file was deleted.
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| plugins { | ||
| id 'java-library' | ||
| id 'jacoco' | ||
| id 'maven-publish' | ||
| } | ||
| 
     | 
||
| dependencies { | ||
| implementation "com.iexec.common:iexec-common:$iexecCommonVersion" | ||
| testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2' | ||
| } | ||
| 
     | 
||
| java { | ||
| withJavadocJar() | ||
| withSourcesJar() | ||
| } | ||
| 
     | 
||
| test { | ||
| useJUnitPlatform() | ||
| } | ||
| 
     | 
||
| jacoco { | ||
| toolVersion = "0.8.7" | ||
| } | ||
| // sonarqube code coverage requires jacoco XML report | ||
| jacocoTestReport { | ||
| reports { | ||
| xml.enabled true | ||
| } | ||
| } | ||
| tasks.test.finalizedBy tasks.jacocoTestReport | ||
| 
     | 
||
| publishing { | ||
| publications { | ||
| maven(MavenPublication) { | ||
| from components.java | ||
| } | ||
| } | ||
| repositories { | ||
| maven { | ||
| credentials { | ||
| username project.hasProperty("nexusUser")? project.nexusUser: '' | ||
| password project.hasProperty("nexusPassword")? project.nexusPassword: '' | ||
| } | ||
| url = project.hasProperty("nexusUrl")? project.nexusUrl: '' | ||
| } | ||
| } | ||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| * Copyright 2022 IEXEC BLOCKCHAIN TECH | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| 
     | 
||
| package com.iexec.blockchain.api; | ||
| 
     | 
||
| import com.iexec.blockchain.tool.Status; | ||
| import com.iexec.common.chain.ChainDataset; | ||
| import com.iexec.common.chain.adapter.args.TaskContributeArgs; | ||
| import com.iexec.common.chain.adapter.args.TaskFinalizeArgs; | ||
| import com.iexec.common.chain.adapter.args.TaskRevealArgs; | ||
| import com.iexec.common.sdk.broker.BrokerOrder; | ||
| import feign.Param; | ||
| import feign.RequestLine; | ||
| 
     | 
||
| /** | ||
| * Interface allowing to instantiate a Feign client targeting Blockchain adapter API REST endpoints. | ||
| * <p> | ||
| * To create the client, call: | ||
| * <pre>FeignBuilder.createBuilder(feignLogLevel) | ||
| * .target(BlockchainAdapterApiClient.class, blockchainAdapterUrl)</pre> | ||
| * @see com.iexec.common.utils.FeignBuilder | ||
| */ | ||
| public interface BlockchainAdapterApiClient { | ||
| 
     | 
||
| //TODO update endpoint | ||
| @RequestLine("POST /broker/broker/orders/match") | ||
| String matchOrders(BrokerOrder brokerOrder); | ||
| 
     | 
||
| @RequestLine("POST /datasets/requests?name={name}&multiAddress={multiAddress}&checksum={checksum}") | ||
| String createDataset(@Param("name") String name, | ||
| @Param("multiAddress") String multiAddress, | ||
| @Param("checksum") String checksum); | ||
| 
     | 
||
| @RequestLine("GET /datasets/requests/{requestId}") | ||
| String getAddressForCreateDatasetRequest(@Param("requestId") String requestId); | ||
| 
     | 
||
| @RequestLine("GET /datasets/requests/{requestId}/status") | ||
| Status getStatusForCreateDatasetRequest(@Param("requestId") String requestId); | ||
| 
     | 
||
| @RequestLine("GET /datasets?address={address}") | ||
| ChainDataset getDatasetByAddress(@Param("address") String address); | ||
| 
     | 
||
| @RequestLine("GET /metrics") | ||
| String getMetrics(); | ||
| 
     | 
||
| @RequestLine("POST /tasks/initialize?chainDealId={chainDealId}&taskIndex={taskIndex}") | ||
| String requestInitializeTask(@Param("chainDealId") String chainDealId, | ||
| @Param("taskIndex") int taskIndex); | ||
| 
     | 
||
| @RequestLine("POST /tasks/contribute/{chainTaskId}") | ||
| String requestContributeTask(@Param("chainTaskId") String chainTaskId, TaskContributeArgs taskContributeArgs); | ||
| 
     | 
||
| @RequestLine("POST /tasks/reveal/{chainTaskId}") | ||
| String requestRevealTask(@Param("chainTaskId") String chainTaskId, TaskRevealArgs taskRevealArgs); | ||
| 
     | 
||
| @RequestLine("POST /tasks/finalize/{chainTaskId}") | ||
| String requestFinalizeTask(@Param("chainTaskId") String chainTaskId, TaskFinalizeArgs taskFinalizeArgs); | ||
| 
     | 
||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.iexec.blockchain.api; | ||
| 
     | 
||
| import com.iexec.common.utils.FeignBuilder; | ||
| import feign.Logger; | ||
| import feign.auth.BasicAuthRequestInterceptor; | ||
| 
     | 
||
| public class BlockchainAdapterApiClientBuilder { | ||
| 
     | 
||
| private BlockchainAdapterApiClientBuilder() {} | ||
| 
     | 
||
| public static BlockchainAdapterApiClient getInstance(Logger.Level logLevel, | ||
| String url, String username, String password) { | ||
| BasicAuthRequestInterceptor requestInterceptor = | ||
| new BasicAuthRequestInterceptor( | ||
| username, | ||
| password | ||
| ); | ||
| return FeignBuilder.createBuilder(logLevel) | ||
| .requestInterceptor(requestInterceptor) | ||
| .target(BlockchainAdapterApiClient.class, url); | ||
| } | ||
| 
     | 
||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.iexec.blockchain.api; | ||
| 
     | 
||
| import feign.Logger; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
| 
     | 
||
| public class BlockchainAdapterApiClientTest { | ||
| 
     | 
||
| @Test | ||
| void instantiationTest() { | ||
| Assertions.assertNotNull(BlockchainAdapterApiClientBuilder | ||
| .getInstance(Logger.Level.FULL, "localhost", "username", "password")); | ||
| } | ||
| 
     | 
||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1 +1,2 @@ | ||
| rootProject.name = 'iexec-blockchain-adapter-api' | ||
| include 'iexec-blockchain-adapter-api-library' | 
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.