Skip to content

Commit f6660bc

Browse files
committed
add some remarks to general concepts
restructure gradle build
1 parent d8962bf commit f6660bc

File tree

19 files changed

+497
-374
lines changed

19 files changed

+497
-374
lines changed

build.gradle

+14-373
Large diffs are not rendered by default.

commercetools/commercetools-sdk-compat-v1/build.gradle

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ dependencies {
1414
api commons.lang3
1515

1616
api project(':commercetools:commercetools-sdk-java-api')
17-
api "com.commercetools.sdk.jvm.core:commercetools-java-client-core" version ctpJvmSdkVersion
17+
api("com.commercetools.sdk.jvm.core:commercetools-java-client-core") {
18+
version ctpJvmSdkVersion
19+
exclude group: 'javax.annotation', module: 'javax.annotation-api'
20+
}
1821

1922
testImplementation project(':commercetools:commercetools-http-client')
2023
testImplementation "com.commercetools.sdk.jvm.core:commercetools-models" version ctpJvmSdkVersion

commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/json/ApiModule.java

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import java.util.Optional;
55

6+
import com.commercetools.api.models.cart.ReplicaCartDraft;
67
import com.commercetools.api.models.product.AttributeImpl;
78
import com.commercetools.api.models.review.Review;
89
import com.commercetools.api.models.type.FieldContainerImpl;
@@ -26,5 +27,6 @@ public ApiModule(ModuleOptions options) {
2627
addDeserializer(AttributeImpl.class, new AtrributeDeserializer(attributeAsDateString));
2728
addDeserializer(FieldContainerImpl.class, new CustomFieldDeserializer(customFieldAsDateString));
2829
setMixInAnnotation(Review.class, ReviewMixin.class);
30+
setMixInAnnotation(ReplicaCartDraft.class, ReplicaCartDraftMixin.class);
2931
}
3032
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
package com.commercetools.api.json;
3+
4+
import com.commercetools.api.models.cart.CartReference;
5+
import com.commercetools.api.models.channel.ChannelReference;
6+
import com.commercetools.api.models.order.OrderReference;
7+
import com.commercetools.api.models.product.ProductReference;
8+
import com.fasterxml.jackson.annotation.JsonSubTypes;
9+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
10+
11+
public interface ReplicaCartDraftMixin {
12+
13+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "typeId", visible = true)
14+
@JsonSubTypes({ @JsonSubTypes.Type(value = CartReference.class, name = "cart"),
15+
@JsonSubTypes.Type(value = OrderReference.class, name = "order") })
16+
public Object getReference();
17+
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.commercetools.docs.meta;
2+
3+
import io.vrap.rmf.base.client.ApiMethod;
4+
5+
/**
6+
* <h2 id=general-concept>General concept of the SDK</h2>
7+
*
8+
* The SDK provides classes and interfaces to interact with the commercetools APIs in an object oriented way.
9+
*
10+
* <h3>ApiHttpClient</h3>
11+
*
12+
* The {@link io.vrap.rmf.base.client.ApiHttpClient} defines the interface to interact with the API. It executes requests
13+
* and maps the response to the correct class and returns it. The ApiHttpClient supports multiple different HTTP client
14+
* implementations and can the behavior can be adjusted using {@link io.vrap.rmf.base.client.http.Middleware middlewares}.
15+
*
16+
* <h3>ApiRoot & ProjectApiRoot</h3>
17+
*
18+
* The {@link com.commercetools.api.client.ApiRoot} and {@link com.commercetools.api.client.ProjectApiRoot} provide a way
19+
* to explore the functionality of the API while coding. All endpoints are reachable using the chainable calls from
20+
* the API root as like as the URI hierarchy of the API describes them. All request builder instances are immutable.
21+
*
22+
* <h3>ApiMethod</h3>
23+
*
24+
* For every resource endpoint and HTTP method a specific {@link io.vrap.rmf.base.client.ApiMethod} exists. It specifies
25+
* the request type and the response return type. Also these classes define methods for the possible query parameters.
26+
* The `with` methods set the parameter to the specified value and drop already defined ones. The `add` methods will
27+
* add an additional parameter with the specified value. The ApiMethod classes are immutable.
28+
*
29+
* The {@link ApiMethod#execute()} and {@link ApiMethod#executeBlocking()} can be used to directly execute the request
30+
* using the configured ApiHttpClient. {@link ApiMethod#send()} and {@link ApiMethod#sendBlocking()} will execute the
31+
* request and return the response as byte array instead of mapping it.
32+
*/
33+
public class GeneralConcept {
34+
}

commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Querying.java

+22
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,28 @@
2323
* <h3>Query all</h3>
2424
*
2525
* {@include.example example.ExamplesTest#queryAll()}
26+
*
27+
* <h3>Sorting</h3>
28+
*
29+
* <p>Please see <a href="https://docs.commercetools.com/api/general-concepts#sorting">Sort</a> for details</p>
30+
*
31+
* <p>Sorting using one parameter:</p>
32+
*
33+
* {@include.example example.ExamplesTest#simpleSort()}
34+
*
35+
* <p>Sorting using multiple parameters:</p>
36+
*
37+
* {@include.example example.ExamplesTest#multiSort()}
38+
*
39+
* <h3 id=pagination>Pagination</h3>
40+
*
41+
* <p>Limiting the number of the returned documents or page size:</p>
42+
*
43+
* {@include.example example.ExamplesTest#limitPagination()}
44+
*
45+
* <p>To retrieve the next results use the offset parameter. The example shows how to retrieve page 2:</p>
46+
*
47+
* {@include.example example.ExamplesTest#limitOffsetPagination()}
2648
*/
2749
public class Querying {
2850
}

commercetools/internal-docs/src/test/java/example/ExamplesTest.java

+37
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,43 @@ public void queryPredicateVariable() {
174174
.withPredicateVar("lastName", "Doe");
175175
}
176176

177+
public void simpleSort() {
178+
ProjectApiRoot apiRoot = createProjectClient();
179+
apiRoot.products()
180+
.get()
181+
.withSort("masterData.current.name.en asc");
182+
}
183+
184+
public void multiSort() {
185+
ProjectApiRoot apiRoot = createProjectClient();
186+
apiRoot.products()
187+
.get()
188+
.withSort("masterData.current.name.en asc")
189+
.addSort("id asc");
190+
}
191+
192+
193+
public void limitPagination() {
194+
ProjectApiRoot apiRoot = createProjectClient();
195+
apiRoot.products()
196+
.get()
197+
.withLimit(4);
198+
199+
apiRoot.products()
200+
.get()
201+
.withLimit(4)
202+
.withOffset(4);
203+
}
204+
205+
public void limitOffsetPagination() {
206+
ProjectApiRoot apiRoot = createProjectClient();
207+
208+
apiRoot.products()
209+
.get()
210+
.withLimit(4)
211+
.withOffset(4);
212+
}
213+
177214
public void queryPredicateVariableArray() {
178215
ProjectApiRoot apiRoot = createProjectClient();
179216
apiRoot.productProjections()

gradle-scripts/alljavadoc.gradle

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
def documentationProjects= [
2+
":commercetools:commercetools-http-client",
3+
":commercetools:commercetools-sdk-java-api",
4+
":commercetools:commercetools-sdk-java-importapi",
5+
":commercetools:commercetools-sdk-java-ml",
6+
":commercetools:commercetools-sdk-compat-v1",
7+
":commercetools:commercetools-sdk-java-history",
8+
":rmf:rmf-java-base",
9+
":commercetools:commercetools-apachehttp-client",
10+
":commercetools:commercetools-okhttp-client3",
11+
":commercetools:commercetools-okhttp-client4",
12+
":commercetools:internal-docs",
13+
":rmf:okhttp-client"
14+
]
15+
16+
task alljavadoc(type: Javadoc) {
17+
source documentationProjects.collect { project(it).sourceSets.main.allJava }
18+
classpath = files(documentationProjects.collect { project(it).sourceSets.test.compileClasspath })
19+
destinationDir = file("${buildDir}/docs/javadoc")
20+
excludes = [
21+
'**/*Test.java',
22+
'**/test/*.java'
23+
]
24+
options {
25+
setMemberLevel JavadocMemberLevel.PUBLIC
26+
setAuthor false
27+
noTimestamp = true
28+
29+
links 'https://docs.oracle.com/javase/8/docs/api/', "https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/${versions.jackson}/", 'https://commercetools.github.io/commercetools-jvm-sdk/apidocs/'
30+
overview = "src/main/javadoc/overview.html"
31+
bottom = """
32+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/styles/default.min.css">
33+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/highlight.min.js"></script>
34+
<script>hljs.initHighlightingOnLoad();</script>
35+
<span id="custom-javascripts"></span>
36+
<script src="{@docRoot}/resources/javascripts/main.js"></script>
37+
<link rel="stylesheet" href="{@docRoot}/resources/stylesheets/main.css">
38+
"""
39+
taglets = ['com.commercetools.build.taglets.CodeTaglet', 'com.commercetools.build.taglets.FileIncludeTaglet', 'org.jdrupes.taglets.plantUml.StartUml', 'org.jdrupes.taglets.plantUml.EndUml', 'org.jdrupes.taglets.plantUml.PlantUml']
40+
tagletPath = configurations.taglet.files as List
41+
addBooleanOption('-allow-script-in-comments', true)
42+
addStringOption('Xdoclint:missing,accessibility,reference', '-quiet')
43+
addBooleanOption('linksource', true)
44+
groups = [
45+
"API": ["com.commercetools.api.*"],
46+
"History": ["com.commercetools.history.*"],
47+
"Import": ["com.commercetools.importapi.*"],
48+
"ML": ["com.commercetools.ml.*"],
49+
"Base Packages": ["io.vrap.rmf.base.*"],
50+
"HTTP Clients": [
51+
"com.commercetools.http.*",
52+
"io.vrap.rmf.okhttp.*"
53+
]
54+
]
55+
addStringOption('source', '8')
56+
}
57+
58+
doLast {
59+
copy{
60+
from "src/main/javadoc/resources"
61+
into "${buildDir}/docs/javadoc/resources"
62+
}
63+
}
64+
}

gradle-scripts/extensions.gradle

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ext {
2+
versions = [
3+
slf4j: "1.7.32",
4+
logback: "1.2.8",
5+
findbugs: "3.0.2",
6+
jackson: "2.12.4",
7+
junit: "5.6.0",
8+
validation: "2.0.1.Final",
9+
assertJ: "3.20.2",
10+
gson: "2.8.8",
11+
awaitility: "4.1.0",
12+
failsafe: "2.4.3",
13+
ctpJvmSdk: {
14+
strictly '[1.62.0,)'
15+
prefer '2.0.0'
16+
}
17+
]
18+
19+
commons = [
20+
lang3: 'org.apache.commons:commons-lang3:3.12.0',
21+
io: {
22+
strictly '[2.8.0,)'
23+
prefer '2.11.0'
24+
}
25+
26+
]
27+
28+
scmProjectName = rootProject.name
29+
scmRepo = 'github.com'
30+
scmProjectPath = "commercetools/commercetools-sdk-java-v2.git" // github relative path with .git extension
31+
scmProjectUrl = "https://$scmRepo/$scmProjectPath" // just as web-page
32+
scmHttpsUrl = "https://$scmRepo/$scmProjectPath" // common VCS read access
33+
scmSshUrl = "git@$scmRepo:$scmProjectPath" // developers VCS read-write repo
34+
SNAPSHOT_SUFFIX = "-SNAPSHOT"
35+
versionWIP = "development$SNAPSHOT_SUFFIX"
36+
}

gradle-scripts/global-tasks.gradle

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
tasks.register("writeVersionToReadme") {
2+
doLast {
3+
ant.replaceregexp(match: 'commercetools: \"[^\\s]+\"', replace: "commercetools: \"${globalVersion}\"", flags:'g', byline:true) {
4+
fileset(dir: projectDir, includes: 'README.md')
5+
}
6+
ant.replaceregexp(match: '<commercetools.version>.+</commercetools.version>', replace: "<commercetools.version>${globalVersion}</commercetools.version>", flags:'g', byline:true) {
7+
fileset(dir: projectDir, includes: 'README.md')
8+
}
9+
}
10+
}
11+
12+
tasks.register("writeVersionToExamples") {
13+
doLast {
14+
ant.replaceregexp(match: 'commercetools: \"[^\\s]+\"', replace: "commercetools: \"${globalVersion}\"", flags:'g', byline:true) {
15+
fileset(dir: projectDir) {
16+
include(name: 'examples/spring/build.gradle')
17+
}
18+
}
19+
ant.replaceregexp(match: '<commercetools.version>.+</commercetools.version>', replace: "<commercetools.version>${globalVersion}</commercetools.version>", flags:'g', byline:true) {
20+
fileset(dir: projectDir) {
21+
include(name: 'examples/maven-okhttp3/pom.xml')
22+
include(name: 'examples/maven-okhttp4/pom.xml')
23+
}
24+
}
25+
}
26+
}

gradle-scripts/jacoco.gradle

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
allprojects {
2+
apply plugin: 'jacoco'
3+
}
4+
5+
task codeCoverageReport(type: JacocoReport) {
6+
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
7+
8+
subprojects.each {
9+
sourceSets it.sourceSets.main
10+
}
11+
12+
reports {
13+
xml.required = true
14+
xml.destination file("${buildDir}/reports/jacoco/report.xml")
15+
html.required = false
16+
csv.required = false
17+
}
18+
}
19+
20+
codeCoverageReport.dependsOn {
21+
subprojects*.test
22+
}

gradle-scripts/licences.gradle

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
licenseReport {
2+
// Set output directory for the report data.
3+
// Defaults to ${project.buildDir}/reports/dependency-license.
4+
outputDir = "$projectDir/build/licenses"
5+
6+
// Adjust the configurations to fetch dependencies, e.g. for Android projects. Default is 'runtimeClasspath'
7+
configurations = ['runtimeClasspath']
8+
// Use 'ALL' to dynamically resolve all configurations:
9+
// configurations = ALL
10+
11+
// Don't exclude bom dependencies.
12+
// If set to true, then all boms will be excluded from the report
13+
excludeBoms = true
14+
15+
// This is for the allowed-licenses-file in checkLicense Task
16+
// Accepts File, URL or String path to local or remote file
17+
allowedLicensesFile = new File("$projectDir/allowed-licenses.json")
18+
}
19+
20+
subprojects {
21+
task allDeps(type: DependencyReportTask) {}
22+
}

0 commit comments

Comments
 (0)