diff --git a/.github/labels.json b/.github/labels.json new file mode 100644 index 00000000..c0b7e81e --- /dev/null +++ b/.github/labels.json @@ -0,0 +1,158 @@ +[ + { + "color": "FF0000", + "description": "Issue reporting or PR addressing a critical problem that blocks other efforts", + "name": "Blocker" + }, + { + "color": "ba0000", + "description": "API breaking change requiring follow-up work in dependant areas", + "name": "Breaking Change" + }, + { + "color": "f5a342", + "description": "Requests, Issues and Changes targeting gradle, groovy, Jenkins, etc.", + "name": "Category: Build/CI" + }, + { + "color": "ff7332", + "description": "Requests, Issues and Changes targeting unexpected terminations, segfaults, etc.", + "name": "Category: Crash" + }, + { + "color": "f5a342", + "description": "Requests, Issues and Changes targeting javadoc and module documentation", + "name": "Category: Doc" + }, + { + "color": "f5a342", + "description": "Requests, Issues and Changes targeting performance", + "name": "Category: Performance" + }, + { + "color": "f5a342", + "description": "Requests, Issues and Changes targeting security", + "name": "Category: Security" + }, + { + "color": "f5a342", + "description": "Requests, Issues and Changes targeting tests and quality assurance", + "name": "Category: Test/QA" + }, + { + "color": "94EC55", + "description": "Good for learners that are new to Terasology", + "name": "Good First Issue" + }, + { + "color": "AAd9d2", + "description": "Very big effort likely requiring a lot of research and work in many areas across the codebase", + "name": "Size: L" + }, + { + "color": "AAd9d2", + "description": "Medium-sized effort likely requiring some research and work in multiple areas", + "name": "Size: M" + }, + { + "color": "AAd9d2", + "description": "Small effort likely only affecting a single area and requiring little to no research", + "name": "Size: S" + }, + { + "color": "ff7d7d", + "description": "Is currently blocked by missing dependencies, pre-requisites, etc.", + "name": "Status: Blocked" + }, + { + "color": "E99695", + "description": "Requires more information by the author on the reported issue or provided changes", + "name": "Status: Needs Author Input" + }, + { + "color": "E99695", + "description": "Requires help discussing a reported issue or provided PR", + "name": "Status: Needs Discussion", + "aliases": ["help wanted"] + }, + { + "color": "E99695", + "description": "Requires to be checked for feasibility, reproducability, etc.", + "name": "Status: Needs Investigation" + }, + { + "color": "E99695", + "description": "Requires to be tested in-game", + "name": "Status: Needs Testing" + }, + { + "color": "DDDDDD", + "description": "Wasn't reviewed or continued for a while", + "name": "Status: Stale" + }, + { + "color": "3b808e", + "description": "Requests, Issues and Changes related to Android-specific features and code.", + "name": "Topic: Anddroid" + }, + { + "color": "3b808e", + "description": "Requests, Issues and Changes related to software architecture, programming patterns, etc.", + "name": "Topic: Architecture" + }, + { + "color": "3b808e", + "description": "Requests, Issues and Changes related to the asset handling library.", + "name": "Topic: Asset" + }, + { + "color": "3b808e", + "description": "Requests, Issues and Changes related to dependency injection (DI) capabilities.", + "name": "Topic: Dependency Injection" + }, + { + "color": "3b808e", + "description": "Requests, Issues and Changes related to improving stablity and reducing flakyness", + "name": "Topic: Stabilization" + }, + { + "color": "3b808e", + "description": "Requests, Issues and Changes related to the entity component system (ECS)", + "name": "Topic: Entity System", + "aliases": ["entitysystem"] + }, + { + "color": "3b808e", + "description": "Requests, Issues and Changes related to gestalt modules", + "name": "Topic: Module", + "aliases": ["gestalt-module"] + }, + { + "color": "d73a4a", + "description": "Issues reporting and PRs fixing problems", + "name": "Type: Bug", + "aliases": ["bug"] + }, + { + "color": "666666", + "description": "Request for or implementation of maintenance changes", + "name": "Type: Chore" + }, + { + "color": "0E8A16", + "description": "Request for or addition/enhancement of a feature", + "name": "Type: Improvement", + "aliases": ["enhancement"] + }, + { + "color": "66CBED", + "description": "Issue intended to help understanding something that is unclear", + "name": "Type: Question", + "aliases": ["question"] + }, + { + "color": "fbca04", + "description": "Request for or implementation of pure and automatic refactorings, e.g. renaming, to improve clarity", + "name": "Type: Refactoring" + } +] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..399e89ac --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,42 @@ +pipeline { + agent { + label "light-java" + } + stages { + stage('Build') { + steps { + sh './gradlew --info --console=plain jar' + } + } + stage('Analytics') { + steps { + sh './gradlew --info --console=plain javadoc check' + } + } + stage('Publish') { + when { + anyOf { + branch 'develop' + branch pattern: "release/v\\d+.x", comparator: "REGEXP" + } + } + steps { + withCredentials([usernamePassword(credentialsId: 'artifactory-gooey', usernameVariable: 'artifactoryUser', passwordVariable: 'artifactoryPass')]) { + sh './gradlew --info --console=plain -Dorg.gradle.internal.publish.checksums.insecure=true publish -PmavenUser=${artifactoryUser} -PmavenPass=${artifactoryPass}' + } + } + } + stage('Record') { + steps { + junit testResults: '**/build/test-results/test/*.xml', allowEmptyResults: true + recordIssues tool: javaDoc() + //Note: Javadoc archiver only works for one directory :-( + //step([$class: 'JavadocArchiver', javadocDir: 'gestalt/build/docs/javadoc', keepAll: false]) + //recordIssues tool: checkStyle(pattern: '**/build/reports/checkstyle/*.xml') + //recordIssues tool: spotBugs(pattern: '**/build/reports/spotbugs/main/*.xml', useRankAsPriority: true) + //recordIssues tool: pmdParser(pattern: '**/build/reports/pmd/*.xml') + recordIssues tool: taskScanner(includePattern: '**/*.java,**/*.groovy,**/*.gradle', lowTags: 'WIBNIF', normalTags: 'TODO', highTags: 'ASAP') + } + } + } +} diff --git a/build.gradle b/build.gradle index 1a6e65fd..f9d55c3f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,66 +1,69 @@ -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +// Only needed for the two Android modules as of April 2021 buildscript { repositories { - google() mavenCentral() - // org.jetbrains.trove4j:trove4j - gradlePluginPortal() - maven { - url 'https://heisluft.de/maven' - } - maven { - url "http://artifactory.terasology.org/artifactory/libs-release-local" - } + // Needed for the Android Gradle Plugin to work + google() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.android.tools.build:gradle:4.1.3' } - ext { - // Android version support - android_annotation_version = "28.0.0" +} - // Standard Utility - guava_version = "27.0.1-android" - slf4j_version = "1.7.25" - gson_version = "2.8.5" - jcip_annotation_version = "1.0" +plugins { + id 'idea' +} - // Testing - junit_version = "4.12" - logback_version = "1.2.3" - mockito_version = "1.10.19" - } +ext { + // Android version support + android_annotation_version = "28.0.0" + + // Standard Utility + guava_version = "27.0.1-android" + slf4j_version = "1.7.25" + gson_version = "2.8.5" + jcip_annotation_version = "1.0" + + // Testing + junit_version = "4.12" + logback_version = "1.2.3" + mockito_version = "1.10.19" } allprojects { repositories { google() mavenCentral() - // org.jetbrains.trove4j:trove4j - gradlePluginPortal() + + // Terasology Artifactory instance for libs not readily available elsewhere plus our own libs maven { - url "http://artifactory.terasology.org/artifactory/libs-release-local" + def repoViaEnv = System.getenv()["RESOLUTION_REPO"] + if (rootProject.hasProperty("alternativeResolutionRepo")) { + // If the user supplies an alternative repo via gradle.properties then use that + name "from alternativeResolutionRepo property" + url alternativeResolutionRepo + } else if (repoViaEnv != null && repoViaEnv != "") { + name "from \$RESOLUTION_REPO" + url = repoViaEnv + } else { + // Our default is the main virtual repo containing everything except repos for testing Artifactory itself + name "Terasology Artifactory" + url "http://artifactory.terasology.org/artifactory/virtual-repo-live" + allowInsecureProtocol true // 😱 + } } + + // SemVer lib maven { url 'https://heisluft.de/maven' } } } -// Library and distribution config -description = 'A set of libraries providing core capabilities for games and game engines' - task clean(type: Delete) { delete rootProject.buildDir } - - diff --git a/gestalt-android-testbed/build.gradle b/gestalt-android-testbed/build.gradle index 701acc5e..91717761 100644 --- a/gestalt-android-testbed/build.gradle +++ b/gestalt-android-testbed/build.gradle @@ -1,19 +1,5 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 apply plugin: 'com.android.application' apply plugin: 'project-report' diff --git a/gestalt-android/build.gradle b/gestalt-android/build.gradle index 2be77008..07d5d0f4 100644 --- a/gestalt-android/build.gradle +++ b/gestalt-android/build.gradle @@ -1,19 +1,5 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 apply plugin: 'com.android.library' apply plugin: 'maven-publish' @@ -84,12 +70,42 @@ project.afterEvaluate { publishing { repositories { maven { - credentials { - username project.gestaltMavenRepoUsername - password project.gestaltMavenRepoPassword + name = 'TerasologyOrg' + allowInsecureProtocol true // 😱 - no https on our Artifactory yet + + if (rootProject.hasProperty("publishRepo")) { + // This first option is good for local testing, you can set a full explicit target repo in gradle.properties + url = "http://artifactory.terasology.org/artifactory/$publishRepo" + + logger.info("Changing PUBLISH repoKey set via Gradle property to {}", publishRepo) + } else { + // Support override from the environment to use a different target publish org + String deducedPublishRepo = System.getenv()["PUBLISH_ORG"] + if (deducedPublishRepo == null || deducedPublishRepo == "") { + // If not then default + deducedPublishRepo = "libs" + } + + // Base final publish repo on whether we're building a snapshot or a release + if (project.version.endsWith('SNAPSHOT')) { + deducedPublishRepo += "-snapshot-local" + } else { + deducedPublishRepo += "-release-local" + } + + logger.info("The final deduced publish repo is {}", deducedPublishRepo) + url = "http://artifactory.terasology.org/artifactory/$deducedPublishRepo" + } + + if (rootProject.hasProperty("mavenUser") && rootProject.hasProperty("mavenPass")) { + credentials { + username = "$mavenUser" + password = "$mavenPass" + } + authentication { + basic(BasicAuthentication) + } } - name 'TerasologyTestRepo' - url project.version.endsWith('SNAPSHOT') ? project.snapshotPublishRepo : project.releasePublishRepo } } publications { @@ -139,4 +155,4 @@ project.afterEvaluate { } } } -} \ No newline at end of file +} diff --git a/gestalt-asset-core/build.gradle b/gestalt-asset-core/build.gradle index 5279eeab..9953589a 100644 --- a/gestalt-asset-core/build.gradle +++ b/gestalt-asset-core/build.gradle @@ -1,28 +1,6 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ - -apply plugin: 'java-library' -apply plugin: 'maven-publish' +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +apply from: "$rootDir/gradle/common.gradle" // Primary dependencies definition dependencies { @@ -30,7 +8,6 @@ dependencies { implementation project(":gestalt-module") implementation project(":gestalt-inject") annotationProcessor project(":gestalt-inject-java") - implementation "com.google.guava:guava:$guava_version" implementation "org.slf4j:slf4j-api:$slf4j_version" @@ -41,10 +18,8 @@ dependencies { testImplementation "junit:junit:$junit_version" testImplementation "ch.qos.logback:logback-classic:$logback_version" testImplementation "org.mockito:mockito-core:$mockito_version" - } - compileJava { inputs.files sourceSets.main.resources.srcDirs options.compilerArgs = ["-Aresource=${sourceSets.main.resources.srcDirs.join(File.pathSeparator)}"] @@ -53,48 +28,3 @@ compileTestJava { inputs.files sourceSets.test.resources.srcDirs options.compilerArgs = ["-Aresource=${sourceSets.test.resources.srcDirs.join(File.pathSeparator)}"] } - - -description = 'Provides support for assets - binary resources that can be loaded from modules or procedurally generated at runtime.' - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - - -/*** - * Publishing - ***/ - -task sourceJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -publishing { - repositories { - maven { - credentials { - username project.gestaltMavenRepoUsername - password project.gestaltMavenRepoPassword - } - name 'TerasologyTestRepo' - url project.version.endsWith('SNAPSHOT') ? project.snapshotPublishRepo : project.releasePublishRepo - } - } - publications { - mavenAssetCore(MavenPublication) { - artifactId = project.name - version = project.version - - from components.java - - artifact sourceJar - artifact javadocJar - } - } -} diff --git a/gestalt-asset-core/src/main/java/org/terasology/gestalt/assets/Asset.java b/gestalt-asset-core/src/main/java/org/terasology/gestalt/assets/Asset.java index b819afe2..8743bf2e 100644 --- a/gestalt-asset-core/src/main/java/org/terasology/gestalt/assets/Asset.java +++ b/gestalt-asset-core/src/main/java/org/terasology/gestalt/assets/Asset.java @@ -85,15 +85,15 @@ protected Iterable>> instances() { } protected void cleanup() { - if(this.parent != null) { + if (this.parent != null) { parent.cleanup(); return; } Iterator>> iter = instances.iterator(); - while(iter.hasNext()) { + while (iter.hasNext()) { WeakReference> reference = iter.next(); Asset inst = reference.get(); - if(inst == null || inst.isDisposed()) { + if (inst == null || inst.isDisposed()) { iter.remove(); } } @@ -105,32 +105,24 @@ protected void cleanup() { * @param urn The urn identifying the asset. * @param assetType The asset type this asset belongs to. */ - public Asset(ResourceUrn urn, AssetType assetType) { + protected Asset(ResourceUrn urn, AssetType assetType) { Preconditions.checkNotNull(urn); Preconditions.checkNotNull(assetType); - instances = urn.isInstance() ? Collections.emptyList(): Lists.newArrayList(); + instances = urn.isInstance() ? Collections.emptyList() : Lists.newArrayList(); this.urn = urn; this.assetType = assetType; assetType.registerAsset(this, disposalHook); } /** - * The constructor for an asset. It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load. + * set a resource handler so the disposable hook can clean up resources not managed by the JVM * - * @param urn The urn identifying the asset. - * @param assetType The asset type this asset belongs to. - * @param resource A resource to close when disposing this class. The resource must not have a reference to this asset - - * this would prevent it being garbage collected. It must be a static inner class, or not contained in the asset class - * (or an anonymous class defined in a static context). A warning will be logged if this is not the case. + * @param resource A resource to close when disposing this class. The resource must not have a reference to this asset - + * this would prevent it being garbage collected. It must be a static inner class, or not contained in the asset class + * (or an anonymous class defined in a static context). A warning will be logged if this is not the case. */ - public Asset(ResourceUrn urn, AssetType assetType, DisposableResource resource) { - Preconditions.checkNotNull(urn); - Preconditions.checkNotNull(assetType); - instances = urn.isInstance() ? Collections.emptyList(): Lists.newArrayList(); - this.urn = urn; - this.assetType = assetType; - disposalHook.setDisposableResource(resource); - assetType.registerAsset(this, disposalHook); + protected void setDisposableResource(DisposableResource resource) { + this.disposalHook.setDisposableResource(resource); } /** @@ -186,7 +178,7 @@ public final > Optional createInstance() { } public final Asset getNormalAsset() { - if(parent == null) { + if (parent == null) { return this; } return parent; @@ -200,7 +192,7 @@ public final synchronized void dispose() { disposed = true; assetType.onAssetDisposed(this); disposalHook.dispose(); - if(parent == null) { + if (parent == null) { for (WeakReference> inst : this.instances()) { Asset current = inst.get(); if (current != null) { diff --git a/gestalt-asset-core/src/test/java/virtualModules/test/stubs/book/Book.java b/gestalt-asset-core/src/test/java/virtualModules/test/stubs/book/Book.java index 24e27272..d42d00c0 100644 --- a/gestalt-asset-core/src/test/java/virtualModules/test/stubs/book/Book.java +++ b/gestalt-asset-core/src/test/java/virtualModules/test/stubs/book/Book.java @@ -35,7 +35,8 @@ public class Book extends Asset { private ImmutableList lines = ImmutableList.of(); public Book(ResourceUrn urn, BookData data, AssetType type) { - super(urn, type, new DisposalAction(urn)); + super(urn, type); + setDisposableResource(new DisposalAction(urn)); reload(data); } diff --git a/gestalt-di/build.gradle b/gestalt-di/build.gradle index 920baed7..32fb0620 100644 --- a/gestalt-di/build.gradle +++ b/gestalt-di/build.gradle @@ -1,8 +1,6 @@ -apply plugin: 'java-library' -apply plugin: 'maven-publish' - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +apply from: "$rootDir/gradle/common.gradle" task gatherJarModules(dependsOn: [':testpack:moduleA:jar', ':testpack:moduleB:jar', ':testpack:moduleC:jar', ':testpack:moduleD:jar'], type: Copy) @@ -21,11 +19,8 @@ dependencies { testImplementation project(":gestalt-module") testImplementation project(":testpack:testpack-api") testImplementation project(":gestalt-entity-system") - } - - gatherJarModules { from '../testpack/moduleA/build/libs/' from '../testpack/moduleB/build/libs/' @@ -37,42 +32,3 @@ gatherJarModules { } test.dependsOn gatherJarModules - - -/*** - * Publishing - ***/ - -task sourceJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -publishing { - repositories { - maven { - credentials { - username project.gestaltMavenRepoUsername - password project.gestaltMavenRepoPassword - } - name 'TerasologyTestRepo' - url project.version.endsWith('SNAPSHOT') ? project.snapshotPublishRepo : project.releasePublishRepo - } - } - publications { - mavenAssetCore(MavenPublication) { - artifactId = project.name - version = project.version - - from components.java - - artifact sourceJar - artifact javadocJar - } - } -} diff --git a/gestalt-entity-system/build.gradle b/gestalt-entity-system/build.gradle index f715b796..d4b565f4 100644 --- a/gestalt-entity-system/build.gradle +++ b/gestalt-entity-system/build.gradle @@ -1,28 +1,6 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ - -apply plugin: 'java-library' -apply plugin: 'maven-publish' +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +apply from: "$rootDir/gradle/common.gradle" // Primary dependencies definition dependencies { @@ -53,59 +31,3 @@ compileTestJava { inputs.files sourceSets.test.resources.srcDirs options.compilerArgs = ["-Aresource=${sourceSets.test.resources.srcDirs.join(File.pathSeparator)}"] } - - -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8" - } -} - -description = 'A threadsafe entity system implementation. ' + - 'An entity system is a component based data model.' - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - - -/*** - * Publishing - ***/ - -task sourceJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -publishing { - repositories { - maven { - credentials { - username project.gestaltMavenRepoUsername - password project.gestaltMavenRepoPassword - } - name 'TerasologyTestRepo' - url project.version.endsWith('SNAPSHOT') ? project.snapshotPublishRepo : project.releasePublishRepo - } - } - publications { - mavenEs(MavenPublication) { - artifactId = project.name - version = project.version - - from components.java - - artifact sourceJar - artifact javadocJar - } - } -} - diff --git a/gestalt-es-perf/build.gradle b/gestalt-es-perf/build.gradle index fc7b561c..d10a6388 100644 --- a/gestalt-es-perf/build.gradle +++ b/gestalt-es-perf/build.gradle @@ -1,28 +1,6 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ - -apply plugin: 'java-library' -apply plugin: 'maven-publish' +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +apply from: "$rootDir/gradle/common.gradle" // Primary dependencies definition dependencies { @@ -35,7 +13,7 @@ dependencies { implementation "org.slf4j:slf4j-api:$slf4j_version" implementation "com.android.support:support-annotations:$android_annotation_version" implementation "net.jcip:jcip-annotations:$jcip_annotation_version" - + testImplementation "junit:junit:$junit_version" testImplementation "ch.qos.logback:logback-classic:$logback_version" testImplementation "org.mockito:mockito-core:$mockito_version" @@ -43,9 +21,6 @@ dependencies { description = 'High performance access methods to replace the use of reflections in gestalt-entity-system. Can be used in Java 7+ and Android API 26+.' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - /*** * Testpack inclusion */ @@ -60,43 +35,3 @@ gatherJarModules { } test.dependsOn gatherModules - -/*** - * Publishing - ***/ - -task sourceJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -publishing { - repositories { - maven { - credentials { - username project.gestaltMavenRepoUsername - password project.gestaltMavenRepoPassword - } - name 'TerasologyTestRepo' - url project.version.endsWith('SNAPSHOT') ? project.snapshotPublishRepo : project.releasePublishRepo - } - } - publications { - mavenEsPerf(MavenPublication) { - artifactId = project.name - version = project.version - - from components.java - - artifact sourceJar - artifact javadocJar - } - } -} - - diff --git a/gestalt-inject-java/build.gradle b/gestalt-inject-java/build.gradle index 39b6391d..5e90d2ee 100644 --- a/gestalt-inject-java/build.gradle +++ b/gestalt-inject-java/build.gradle @@ -1,37 +1,6 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ - -apply plugin: 'java-library' -apply plugin: 'maven-publish' - -repositories { - maven { - url = 'https://heisluft.tk/maven/' - } -} - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +apply from: "$rootDir/gradle/common.gradle" // Primary dependencies definition dependencies { @@ -51,45 +20,4 @@ dependencies { implementation 'com.squareup:javapoet:1.12.0' implementation group: 'javax.inject', name: 'javax.inject', version: '1' implementation project(":gestalt-inject"); - } - - -/*** - * Publishing - ***/ - -task sourceJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -publishing { - repositories { - maven { - credentials { - username project.gestaltMavenRepoUsername - password project.gestaltMavenRepoPassword - } - name 'TerasologyTestRepo' - url project.version.endsWith('SNAPSHOT') ? project.snapshotPublishRepo : project.releasePublishRepo - } - } - publications { - mavenAssetCore(MavenPublication) { - artifactId = project.name - version = project.version - - from components.java - - artifact sourceJar - artifact javadocJar - } - } -} - diff --git a/gestalt-inject/build.gradle b/gestalt-inject/build.gradle index 7cbf5d34..70338303 100644 --- a/gestalt-inject/build.gradle +++ b/gestalt-inject/build.gradle @@ -1,8 +1,6 @@ -apply plugin: 'java-library' -apply plugin: 'maven-publish' - -repositories { -} +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +apply from: "$rootDir/gradle/common.gradle" // Primary dependencies definition dependencies { @@ -10,45 +8,3 @@ dependencies { implementation "org.slf4j:slf4j-api:$slf4j_version" implementation "com.google.guava:guava:$guava_version" } - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - - -/*** - * Publishing - ***/ - -task sourceJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -publishing { - repositories { - maven { - credentials { - username project.gestaltMavenRepoUsername - password project.gestaltMavenRepoPassword - } - name 'TerasologyTestRepo' - url project.version.endsWith('SNAPSHOT') ? project.snapshotPublishRepo : project.releasePublishRepo - } - } - publications { - mavenAssetCore(MavenPublication) { - artifactId = project.name - version = project.version - - from components.java - - artifact sourceJar - artifact javadocJar - } - } -} diff --git a/gestalt-module/build.gradle b/gestalt-module/build.gradle index ea4975a8..2cc80fb7 100644 --- a/gestalt-module/build.gradle +++ b/gestalt-module/build.gradle @@ -1,34 +1,6 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ - -apply plugin: 'java-library' -apply plugin: 'maven-publish' - -repositories { - maven { - url = 'https://heisluft.de/maven/' - } -} +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +apply from: "$rootDir/gradle/common.gradle" // Primary dependencies definition dependencies { @@ -66,9 +38,6 @@ compileTestJava { // Library and distribution config description = 'Provides support for modules - java libraries that can be activated at runtime and run in a sandboxed environment' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - task gatherJarModules(dependsOn: [':testpack:moduleA:jar', ':testpack:moduleB:jar', ':testpack:moduleC:jar', ':testpack:moduleD:jar'], type: Copy) task createModuleE(dependsOn: [':gestalt-module:copyModuleEInfo', ':gestalt-module:copyModuleELibs']) task copyModuleELibs(dependsOn: [':testpack:moduleA:jar', ':testpack:moduleD:jar'], type: Copy) @@ -98,42 +67,3 @@ gatherJarModules { } test.dependsOn gatherModules - -/*** - * Publishing - ***/ - -task sourceJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -publishing { - repositories { - maven { - credentials { - username project.gestaltMavenRepoUsername - password project.gestaltMavenRepoPassword - } - name 'TerasologyTestRepo' - url project.version.endsWith('SNAPSHOT') ? project.snapshotPublishRepo : project.releasePublishRepo - } - } - publications { - mavenModule(MavenPublication) { - artifactId = project.name - version = project.version - - from components.java - - artifact sourceJar - artifact javadocJar - } - } -} - diff --git a/gestalt-util/build.gradle b/gestalt-util/build.gradle index c9e52e69..4dd9e0e7 100644 --- a/gestalt-util/build.gradle +++ b/gestalt-util/build.gradle @@ -1,28 +1,6 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ - -apply plugin: 'java-library' -apply plugin: 'maven-publish' +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 +apply from: "$rootDir/gradle/common.gradle" // Primary dependencies definition dependencies { @@ -36,48 +14,3 @@ dependencies { testImplementation "ch.qos.logback:logback-classic:$logback_version" testImplementation "org.mockito:mockito-core:$mockito_version" } - -// Library and distribution config -description = 'Common utility classes' - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -/*** - * Publishing - ***/ - -task sourceJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -publishing { - repositories { - maven { - credentials { - username project.gestaltMavenRepoUsername - password project.gestaltMavenRepoPassword - } - name 'TerasologyTestRepo' - url project.version.endsWith('SNAPSHOT') ? project.snapshotPublishRepo : project.releasePublishRepo - } - } - publications { - mavenUtil(MavenPublication) { - artifactId = project.name - version = project.version - - from components.java - - artifact sourceJar - artifact javadocJar - } - } -} - diff --git a/gradle.properties b/gradle.properties index a861bbc1..1bc16494 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,15 @@ org.gradle.jvmargs=-Xmx1536m group=org.terasology.gestalt -version=7.0.7-SNAPSHOT -# Where to publish artifacts, if not to the default snapshot/release repos +version=8.0.0-SNAPSHOT + +# Alternative resolution repo to use - this can be used to ignore "live" artifacts and only accept experimental ones. +# alternativeResolutionRepo=http://artifactory.terasology.org/artifactory/virtual-nanoware-and-remote + +#Where to publish artifacts, if not to the default snapshot/release repos # Publishing a snapshot to a release-only repo will get an intended but quirky HTTP 409 Conflict error as of Nov 2014 -snapshotPublishRepo=http://artifactory.terasology.org/artifactory/libs-snapshot-local -releasePublishRepo=http://artifactory.terasology.org/artifactory/libs-release-local -# Override these values in ~/.gradle/gradle.properties -gestaltMavenRepoUsername= -gestaltMavenRepoPassword= +#publishRepo=nanoware-snapshot-local + +# Credentials for publishing to Artifactory. Consider setting in ~/.gradle/gradle.properties +# REMEMBER TO NOT CHECK IN ACTUAL CREDENTIAL FROM HERE! +#mavenUser= +#mavenPass= diff --git a/gradle/common.gradle b/gradle/common.gradle new file mode 100644 index 00000000..eef1012b --- /dev/null +++ b/gradle/common.gradle @@ -0,0 +1,88 @@ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 + +// Most typical common config, but not quite global +apply plugin: 'java-library' +apply plugin: 'maven-publish' + +java { + withSourcesJar() + withJavadocJar() + + sourceCompatibility(JavaVersion.VERSION_1_8) + targetCompatibility(JavaVersion.VERSION_1_8) +} + +// Extra details provided for unit tests +test { + useJUnit() + + // ignoreFailures: Specifies whether the build should break when the verifications performed by this task fail. + ignoreFailures = true + + // showStandardStreams: makes the standard streams (err and out) visible at console when running tests + testLogging.showStandardStreams = true + + reports { + junitXml.enabled = true + } + + // Arguments to include while running tests + jvmArgs '-Xms512m', '-Xmx1024m' +} + +// In theory all Javadoc should be good and fixed, but it might be a bit much to entirely fail a build over. For now at least ... +// Note: In IntelliJ 2020.1+ running a javadoc Gradle task may still *look* alarming in the UI, but errors should be ignored +javadoc { + failOnError = false +} + +publishing { + publications { + "$project.name"(MavenPublication) { + // Without this we get a .pom with no dependencies + from components.java + + repositories { + maven { + name = 'TerasologyOrg' + allowInsecureProtocol true // 😱 - no https on our Artifactory yet + + if (rootProject.hasProperty("publishRepo")) { + // This first option is good for local testing, you can set a full explicit target repo in gradle.properties + url = "http://artifactory.terasology.org/artifactory/$publishRepo" + + logger.info("Changing PUBLISH repoKey set via Gradle property to {}", publishRepo) + } else { + // Support override from the environment to use a different target publish org + String deducedPublishRepo = System.getenv()["PUBLISH_ORG"] + if (deducedPublishRepo == null || deducedPublishRepo == "") { + // If not then default + deducedPublishRepo = "libs" + } + + // Base final publish repo on whether we're building a snapshot or a release + if (project.version.endsWith('SNAPSHOT')) { + deducedPublishRepo += "-snapshot-local" + } else { + deducedPublishRepo += "-release-local" + } + + logger.info("The final deduced publish repo is {}", deducedPublishRepo) + url = "http://artifactory.terasology.org/artifactory/$deducedPublishRepo" + } + + if (rootProject.hasProperty("mavenUser") && rootProject.hasProperty("mavenPass")) { + credentials { + username = "$mavenUser" + password = "$mavenPass" + } + authentication { + basic(BasicAuthentication) + } + } + } + } + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e04263a8..141bd3ca 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip diff --git a/testpack/moduleA/build.gradle b/testpack/moduleA/build.gradle index dae839b7..1fec05d8 100644 --- a/testpack/moduleA/build.gradle +++ b/testpack/moduleA/build.gradle @@ -1,25 +1,5 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 apply plugin: 'java' jar { diff --git a/testpack/moduleB/build.gradle b/testpack/moduleB/build.gradle index dae839b7..1fec05d8 100644 --- a/testpack/moduleB/build.gradle +++ b/testpack/moduleB/build.gradle @@ -1,25 +1,5 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 apply plugin: 'java' jar { diff --git a/testpack/moduleC/build.gradle b/testpack/moduleC/build.gradle index 1b5fa952..1fec05d8 100644 --- a/testpack/moduleC/build.gradle +++ b/testpack/moduleC/build.gradle @@ -1,26 +1,5 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ - +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 apply plugin: 'java' jar { diff --git a/testpack/moduleD/build.gradle b/testpack/moduleD/build.gradle index 1b5fa952..1fec05d8 100644 --- a/testpack/moduleD/build.gradle +++ b/testpack/moduleD/build.gradle @@ -1,26 +1,5 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ - +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 apply plugin: 'java' jar { diff --git a/testpack/moduleF/build.gradle b/testpack/moduleF/build.gradle index f48dddb3..f42abae5 100644 --- a/testpack/moduleF/build.gradle +++ b/testpack/moduleF/build.gradle @@ -1,4 +1,5 @@ - +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 apply plugin: 'java' jar { diff --git a/testpack/testpack-api/build.gradle b/testpack/testpack-api/build.gradle index 03afc8c4..3f454db7 100644 --- a/testpack/testpack-api/build.gradle +++ b/testpack/testpack-api/build.gradle @@ -1,31 +1,11 @@ -/* - * Copyright 2019 MovingBlocks - * - * 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. - */ - -/* - * This is a Gradle build file: - * - Gradle Homepage: http://gradle.org/ - * - Gradle Documentation: http://gradle.org/documentation - * - View tasks for this project: $ gradlew tasks - */ - +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 apply plugin: 'java' dependencies { annotationProcessor project(":gestalt-inject-java") implementation project(":gestalt-inject") } + sourceCompatibility = 1.8 targetCompatibility = 1.8