Skip to content

Commit 58cb44f

Browse files
authored
Merge pull request #44 from JavaSaBr/extend-api-part-2
Extend API, part 2
2 parents e760efa + dbcb663 commit 58cb44f

127 files changed

Lines changed: 4629 additions & 3875 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 1 addition & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,10 @@
11
rootProject.version = "10.0.alpha1"
22
group = 'javasabr.rlib'
33

4-
subprojects {
5-
4+
allprojects {
65
repositories {
76
mavenCentral()
87
}
9-
10-
apply plugin: "java-library"
11-
apply plugin: "jacoco"
12-
apply plugin: "jacoco-report-aggregation"
13-
apply plugin: "java-test-fixtures"
14-
apply plugin: 'maven-publish'
15-
16-
java {
17-
toolchain {
18-
languageVersion = JavaLanguageVersion.of(21)
19-
}
20-
}
21-
22-
javadoc {
23-
failOnError = false
24-
}
25-
26-
test {
27-
useJUnitPlatform()
28-
failOnNoDiscoveredTests = false
29-
}
30-
31-
dependencies {
32-
compileOnly libs.jspecify
33-
compileOnly libs.lombok
34-
annotationProcessor libs.lombok
35-
36-
testImplementation libs.junit.api
37-
testImplementation libs.junit.jupiter.params
38-
testCompileOnly libs.lombok
39-
testCompileOnly libs.jspecify
40-
testRuntimeOnly libs.junit.engine
41-
testRuntimeOnly libs.junit.platform.launcher
42-
testAnnotationProcessor libs.lombok
43-
}
44-
45-
/*compileJava {
46-
inputs.property("moduleName", jar.baseName)
47-
doFirst {
48-
options.compilerArgs = [
49-
'--module-path', classpath.asPath,
50-
]
51-
classpath = files()
52-
}
53-
}*/
54-
55-
tasks.withType(JavaCompile).configureEach {
56-
options.encoding = "UTF-8"
57-
}
58-
59-
tasks.withType(Javadoc).configureEach {
60-
options.encoding = "UTF-8"
61-
}
62-
63-
tasks.register("sourcesJar", Jar) {
64-
dependsOn "classes"
65-
group "build"
66-
archiveClassifier = "sources"
67-
archiveBaseName = jar.archiveBaseName
68-
from sourceSets.main.allSource
69-
}
70-
71-
tasks.register("javadocJar", Jar) {
72-
dependsOn "javadoc"
73-
group "build"
74-
archiveClassifier = "javadoc"
75-
archiveBaseName = jar.archiveBaseName
76-
from sourceSets.main.allSource
77-
}
78-
79-
publishing {
80-
repositories {
81-
maven {
82-
name = "GitlabPackages"
83-
url = uri("https://gitlab.com/api/v4/projects/37512056/packages/maven")
84-
credentials(HttpHeaderCredentials) {
85-
name = "Private-Token"
86-
value = project.findProperty("gitlab.token") ?: System.getenv("GITLAB_TOKEN")
87-
}
88-
authentication {
89-
header(HttpHeaderAuthentication)
90-
}
91-
}
92-
}
93-
94-
publications {
95-
mavenJava(MavenPublication) {
96-
from components.java
97-
version = rootProject.version
98-
afterEvaluate {
99-
artifactId = jar.archiveBaseName.get()
100-
groupId = rootProject.group
101-
}
102-
artifact sourcesJar
103-
artifact javadocJar
104-
}
105-
}
106-
}
107-
108-
configurations {
109-
testArtifacts.extendsFrom testRuntime
110-
}
111-
112-
tasks.register('testJar', Jar) {
113-
archiveClassifier = "test"
114-
from sourceSets.test.output
115-
}
116-
117-
artifacts {
118-
testArtifacts testJar
119-
}
120-
121-
tasks.withType(Test).configureEach {
122-
maxParallelForks = Runtime.runtime.availableProcessors()
123-
}
124-
125-
jacocoTestReport {
126-
dependsOn test
127-
reports {
128-
xml.required = false
129-
csv.required = false
130-
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
131-
}
132-
}
1338
}
1349

13510
wrapper {

buildSrc/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
id 'groovy-gradle-plugin'
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
gradlePluginPortal()
8+
}

buildSrc/settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
2+
3+
rootProject.name = 'rlib-build-configuration'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
id "jacoco"
3+
}
4+
5+
jacocoTestReport {
6+
dependsOn test
7+
reports {
8+
xml.required = false
9+
csv.required = false
10+
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
11+
}
12+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
plugins {
2+
id("java-library")
3+
id("java-test-fixtures")
4+
id("configure-jacoco")
5+
}
6+
7+
repositories {
8+
mavenCentral()
9+
}
10+
11+
java {
12+
toolchain {
13+
languageVersion = JavaLanguageVersion.of(21)
14+
}
15+
}
16+
17+
sourceSets {
18+
loadTest {
19+
compileClasspath += main.output
20+
compileClasspath += main.compileClasspath
21+
compileClasspath += test.compileClasspath
22+
runtimeClasspath += main.output
23+
runtimeClasspath += main.compileClasspath
24+
runtimeClasspath += test.compileClasspath
25+
java {
26+
srcDirs = ["src/loadTest/java"]
27+
}
28+
}
29+
}
30+
31+
javadoc {
32+
failOnError = false
33+
}
34+
35+
test {
36+
useJUnitPlatform()
37+
failOnNoDiscoveredTests = false
38+
}
39+
40+
tasks.register("loadTest", Test) {
41+
group("verification")
42+
useJUnitPlatform()
43+
failOnNoDiscoveredTests = false
44+
testClassesDirs = sourceSets.loadTest.output.classesDirs
45+
classpath = sourceSets.loadTest.runtimeClasspath
46+
minHeapSize = "128m"
47+
maxHeapSize = "4G"
48+
}
49+
50+
dependencies {
51+
compileOnly libs.jspecify
52+
compileOnly libs.lombok
53+
annotationProcessor libs.lombok
54+
55+
testImplementation libs.junit.api
56+
testImplementation libs.junit.jupiter.params
57+
58+
testCompileOnly libs.lombok
59+
testCompileOnly libs.jspecify
60+
testRuntimeOnly libs.junit.engine
61+
testRuntimeOnly libs.junit.platform.launcher
62+
testAnnotationProcessor libs.lombok
63+
64+
loadTestCompileOnly libs.lombok
65+
loadTestCompileOnly libs.jspecify
66+
loadTestRuntimeOnly libs.junit.engine
67+
loadTestRuntimeOnly libs.junit.platform.launcher
68+
loadTestAnnotationProcessor libs.lombok
69+
}
70+
71+
tasks.withType(JavaCompile).configureEach {
72+
options.encoding = "UTF-8"
73+
}
74+
75+
tasks.withType(Javadoc).configureEach {
76+
options.encoding = "UTF-8"
77+
}
78+
79+
tasks.register("sourcesJar", Jar) {
80+
dependsOn "classes"
81+
group "build"
82+
archiveClassifier = "sources"
83+
archiveBaseName = jar.archiveBaseName
84+
from sourceSets.main.allSource
85+
}
86+
87+
tasks.register("javadocJar", Jar) {
88+
dependsOn "javadoc"
89+
group "build"
90+
archiveClassifier = "javadoc"
91+
archiveBaseName = jar.archiveBaseName
92+
from sourceSets.main.allSource
93+
}
94+
95+
configurations {
96+
testArtifacts.extendsFrom testRuntime
97+
}
98+
99+
tasks.register('testJar', Jar) {
100+
archiveClassifier = "test"
101+
from sourceSets.test.output
102+
}
103+
104+
artifacts {
105+
testArtifacts testJar
106+
}
107+
108+
tasks.withType(Test).configureEach {
109+
maxParallelForks = Runtime.runtime.availableProcessors()
110+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
plugins {
2+
id("maven-publish")
3+
}
4+
5+
publishing {
6+
repositories {
7+
maven {
8+
name = "GitlabPackages"
9+
url = uri("https://gitlab.com/api/v4/projects/37512056/packages/maven")
10+
credentials(HttpHeaderCredentials) {
11+
name = "Private-Token"
12+
value = project.findProperty("gitlab.token") ?: System.getenv("GITLAB_TOKEN")
13+
}
14+
authentication {
15+
header(HttpHeaderAuthentication)
16+
}
17+
}
18+
}
19+
20+
publications {
21+
mavenJava(MavenPublication) {
22+
from components.java
23+
version = rootProject.version
24+
afterEvaluate {
25+
artifactId = jar.archiveBaseName.get()
26+
groupId = rootProject.group
27+
}
28+
artifact sourcesJar
29+
artifact javadocJar
30+
}
31+
}
32+
}

lombok.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lombok.log.custom.declaration = javasabr.rlib.logger.api.Logger javasabr.rlib.logger.api.LoggerManager.getLogger(TYPE)

rlib-classpath/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
plugins {
2+
id("configure-java")
3+
id("configure-publishing")
4+
}
15

26
dependencies {
37
api projects.rlibCommon

rlib-collections/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
plugins {
2+
id("configure-java")
3+
id("configure-publishing")
4+
}
15

26
dependencies {
37
api projects.rlibCommon

rlib-collections/src/main/java/javasabr/rlib/collections/deque/impl/AbstractArrayBasedDeque.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ public boolean offerLast(E element) {
111111
protected abstract void incrementSize();
112112
protected abstract void decrementSize();
113113

114+
protected abstract int decrementSizeAndGet();
115+
114116
protected @Nullable E[] increaseLeft(@Nullable E[] items, int size) {
115117

116118
int stepSize = stepSize(items);
@@ -177,13 +179,17 @@ public E removeFirst() {
177179
E item = items[head];
178180
items[head] = null;
179181

180-
decrementSize();
181-
int newHead = incrementHeadAndGet();
182+
int newSize = decrementSizeAndGet();
183+
if (newSize == 0) {
184+
resetIndexes();
185+
//noinspection DataFlowIssue
186+
return item;
187+
}
182188

189+
int newHead = incrementHeadAndGet();
183190
if (head == tail()) {
184191
tail(newHead);
185192
}
186-
187193
if (newHead > rebalanceTrigger()) {
188194
rebalance();
189195
}
@@ -205,13 +211,17 @@ public E removeLast() {
205211
E item = items[tail];
206212
items[tail] = null;
207213

208-
decrementSize();
209-
int newTail = decrementTailAndGet();
214+
int newSize = decrementSizeAndGet();
215+
if (newSize == 0) {
216+
resetIndexes();
217+
//noinspection DataFlowIssue
218+
return item;
219+
}
210220

221+
int newTail = decrementTailAndGet();
211222
if (tail == head()) {
212223
head(newTail);
213224
}
214-
215225
if (items.length - tail > rebalanceTrigger()) {
216226
rebalance();
217227
}

0 commit comments

Comments
 (0)