Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 1 addition & 126 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,135 +1,10 @@
rootProject.version = "10.0.alpha1"
group = 'javasabr.rlib'

subprojects {

allprojects {
repositories {
mavenCentral()
}

apply plugin: "java-library"
apply plugin: "jacoco"
apply plugin: "jacoco-report-aggregation"
apply plugin: "java-test-fixtures"
apply plugin: 'maven-publish'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

javadoc {
failOnError = false
}

test {
useJUnitPlatform()
failOnNoDiscoveredTests = false
}

dependencies {
compileOnly libs.jspecify
compileOnly libs.lombok
annotationProcessor libs.lombok

testImplementation libs.junit.api
testImplementation libs.junit.jupiter.params
testCompileOnly libs.lombok
testCompileOnly libs.jspecify
testRuntimeOnly libs.junit.engine
testRuntimeOnly libs.junit.platform.launcher
testAnnotationProcessor libs.lombok
}

/*compileJava {
inputs.property("moduleName", jar.baseName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}*/

tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}

tasks.withType(Javadoc).configureEach {
options.encoding = "UTF-8"
}

tasks.register("sourcesJar", Jar) {
dependsOn "classes"
group "build"
archiveClassifier = "sources"
archiveBaseName = jar.archiveBaseName
from sourceSets.main.allSource
}

tasks.register("javadocJar", Jar) {
dependsOn "javadoc"
group "build"
archiveClassifier = "javadoc"
archiveBaseName = jar.archiveBaseName
from sourceSets.main.allSource
}

publishing {
repositories {
maven {
name = "GitlabPackages"
url = uri("https://gitlab.com/api/v4/projects/37512056/packages/maven")
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = project.findProperty("gitlab.token") ?: System.getenv("GITLAB_TOKEN")
}
authentication {
header(HttpHeaderAuthentication)
}
}
}

publications {
mavenJava(MavenPublication) {
from components.java
version = rootProject.version
afterEvaluate {
artifactId = jar.archiveBaseName.get()
groupId = rootProject.group
}
artifact sourcesJar
artifact javadocJar
}
}
}

configurations {
testArtifacts.extendsFrom testRuntime
}

tasks.register('testJar', Jar) {
archiveClassifier = "test"
from sourceSets.test.output
}

artifacts {
testArtifacts testJar
}

tasks.withType(Test).configureEach {
maxParallelForks = Runtime.runtime.availableProcessors()
}

jacocoTestReport {
dependsOn test
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}
}

wrapper {
Expand Down
8 changes: 8 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id 'groovy-gradle-plugin'
}

repositories {
mavenCentral()
gradlePluginPortal()
}
3 changes: 3 additions & 0 deletions buildSrc/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

rootProject.name = 'rlib-build-configuration'
12 changes: 12 additions & 0 deletions buildSrc/src/main/groovy/configure-jacoco.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
id "jacoco"
}

jacocoTestReport {
dependsOn test
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}
110 changes: 110 additions & 0 deletions buildSrc/src/main/groovy/configure-java.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
plugins {
id("java-library")
id("java-test-fixtures")
id("configure-jacoco")
}

repositories {
mavenCentral()
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

sourceSets {
loadTest {
compileClasspath += main.output
compileClasspath += main.compileClasspath
compileClasspath += test.compileClasspath
runtimeClasspath += main.output
runtimeClasspath += main.compileClasspath
runtimeClasspath += test.compileClasspath
java {
srcDirs = ["src/loadTest/java"]
}
}
}

javadoc {
failOnError = false
}

test {
useJUnitPlatform()
failOnNoDiscoveredTests = false
}

tasks.register("loadTest", Test) {
group("verification")
useJUnitPlatform()
failOnNoDiscoveredTests = false
testClassesDirs = sourceSets.loadTest.output.classesDirs
classpath = sourceSets.loadTest.runtimeClasspath
minHeapSize = "128m"
maxHeapSize = "4G"
}

dependencies {
compileOnly libs.jspecify
compileOnly libs.lombok
annotationProcessor libs.lombok

testImplementation libs.junit.api
testImplementation libs.junit.jupiter.params

testCompileOnly libs.lombok
testCompileOnly libs.jspecify
testRuntimeOnly libs.junit.engine
testRuntimeOnly libs.junit.platform.launcher
testAnnotationProcessor libs.lombok

loadTestCompileOnly libs.lombok
loadTestCompileOnly libs.jspecify
loadTestRuntimeOnly libs.junit.engine
loadTestRuntimeOnly libs.junit.platform.launcher
loadTestAnnotationProcessor libs.lombok
}

tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}

tasks.withType(Javadoc).configureEach {
options.encoding = "UTF-8"
}

tasks.register("sourcesJar", Jar) {
dependsOn "classes"
group "build"
archiveClassifier = "sources"
archiveBaseName = jar.archiveBaseName
from sourceSets.main.allSource
}

tasks.register("javadocJar", Jar) {
dependsOn "javadoc"
group "build"
archiveClassifier = "javadoc"
archiveBaseName = jar.archiveBaseName
from sourceSets.main.allSource
}

configurations {
testArtifacts.extendsFrom testRuntime
}

tasks.register('testJar', Jar) {
archiveClassifier = "test"
from sourceSets.test.output
}

artifacts {
testArtifacts testJar
}

tasks.withType(Test).configureEach {
maxParallelForks = Runtime.runtime.availableProcessors()
}
32 changes: 32 additions & 0 deletions buildSrc/src/main/groovy/configure-publishing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
plugins {
id("maven-publish")
}

publishing {
repositories {
maven {
name = "GitlabPackages"
url = uri("https://gitlab.com/api/v4/projects/37512056/packages/maven")
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = project.findProperty("gitlab.token") ?: System.getenv("GITLAB_TOKEN")
}
authentication {
header(HttpHeaderAuthentication)
}
}
}

publications {
mavenJava(MavenPublication) {
from components.java
version = rootProject.version
afterEvaluate {
artifactId = jar.archiveBaseName.get()
groupId = rootProject.group
}
artifact sourcesJar
artifact javadocJar
}
}
}
1 change: 1 addition & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.log.custom.declaration = javasabr.rlib.logger.api.Logger javasabr.rlib.logger.api.LoggerManager.getLogger(TYPE)
4 changes: 4 additions & 0 deletions rlib-classpath/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("configure-java")
id("configure-publishing")
}

dependencies {
api projects.rlibCommon
Expand Down
4 changes: 4 additions & 0 deletions rlib-collections/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("configure-java")
id("configure-publishing")
}

dependencies {
api projects.rlibCommon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public boolean offerLast(E element) {
protected abstract void incrementSize();
protected abstract void decrementSize();

protected abstract int decrementSizeAndGet();

protected @Nullable E[] increaseLeft(@Nullable E[] items, int size) {

int stepSize = stepSize(items);
Expand Down Expand Up @@ -177,13 +179,17 @@ public E removeFirst() {
E item = items[head];
items[head] = null;

decrementSize();
int newHead = incrementHeadAndGet();
int newSize = decrementSizeAndGet();
if (newSize == 0) {
resetIndexes();
//noinspection DataFlowIssue
return item;
}

int newHead = incrementHeadAndGet();
if (head == tail()) {
tail(newHead);
}

if (newHead > rebalanceTrigger()) {
rebalance();
}
Expand All @@ -205,13 +211,17 @@ public E removeLast() {
E item = items[tail];
items[tail] = null;

decrementSize();
int newTail = decrementTailAndGet();
int newSize = decrementSizeAndGet();
if (newSize == 0) {
resetIndexes();
//noinspection DataFlowIssue
return item;
}

int newTail = decrementTailAndGet();
if (tail == head()) {
head(newTail);
}

if (items.length - tail > rebalanceTrigger()) {
rebalance();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ protected void incrementSize() {
protected void decrementSize() {
size--;
}

@Override
protected int decrementSizeAndGet() {
return --size;
}
}
Loading
Loading