Skip to content
This repository has been archived by the owner on Apr 18, 2020. It is now read-only.

Fabricization #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions .github/workflows/gradlepublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java#publishing-using-gradle

name: Gradle Package

on: push

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Gradle
run: gradle build

# The USERNAME and PASSWORD need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
run: gradle publish
env:
BRANCH_NAME: ${{ github.ref }}
RUN_COUNT: ${{ github.run_number }}
REPO_NAME: ${{ github.repository }}
USERNAME: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
33 changes: 29 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
.idea/
build/
run/
.gradle/
# Compiled nonsense that does not belong in *source* control
/build
/bin
/.gradle
/minecraft
/out
/run
/classes

# IDE nonsense that could go in source control but really shouldn't
.classpath
.project
.metadata
.settings
*.launch
*.iml
.idea
*.ipr
*.iws

# Sekrit files
private.properties
private.gradle

# Files from bad operating systems :^)
Thumbs.db
.DS_Store
local.properties
.directory
15 changes: 11 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
Copyright 2019 Martmists
Copyright 2020 FabLabsMC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we can keep this in FabLabs, then.


Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
133 changes: 118 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,128 @@
buildscript {
dependencies {
classpath "net.fabricmc:fabric-loom:0.2.7-SNAPSHOT"
plugins {
id "java"
id "eclipse"
id "idea"
id "fabric-loom" version "0.2.7-SNAPSHOT"
id "maven-publish"
id "checkstyle"
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

// Elytra version format - notes branch, commit count, and dirty in version string
def branch
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs cleaning up

if (System.env.BRANCH_NAME) {
// CI support
branch = System.env.BRANCH_NAME
branch = branch.substring(branch.lastIndexOf("/")+1)
} else {
branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
}
if (branch == "HEAD") {
branch = "git rev-parse --short HEAD".execute().in.text.trim()
}
def commits
if (System.env.RUN_COUNT) {
//CI support, for some reason github actions doesn't like getting the rev-list count
commits = System.env.RUN_COUNT
} else {
commits = "git rev-list --count HEAD".execute().in.text.trim()
}
def dirty = !"git diff-index HEAD".execute().in.text.trim().isEmpty()

def libName = "${project.library_name}"
def libVer = "${project.library_version}"
archivesBaseName = "fablabs-" + libName + "-v" + libVer
group = "${project.maven_group}"
version = branch + "-${project.mod_version}" + "." + commits + (dirty ? "-dirty" : "") + "+${project.minecraft_version}"
def modVersion = "${project.mod_version}" + "-" + commits + "+${project.minecraft_version}" // semver-compatible version string for use in fabric.mod.json
def modRepo
if (System.env.REPO_NAME) {
modRepo = System.env.REPO_NAME
} else {
modRepo = "FabLabsMC/${project.library_name}"
}

minecraft {
accessWidener = file("src/main/resources/libgamerule.accesswidener")
}

repositories {
mavenCentral()
maven { url "http://maven.fabricmc.net/" } // Fabric maven - home of Fabric API and ModMenu
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_build}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// compileOnly "com.google.code.findbugs:jsr305:3.0.2" //TODO: what are we going to do for annotations?
}

checkstyle {
configFile = rootProject.file("checkstyle.xml")
toolVersion = '8.25'
}

processResources {
inputs.property "version", modVersion
inputs.property "id", project.archivesBaseName
inputs.property "repo", modRepo
inputs.property "libname", libName
inputs.property "libver", libVer
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand version: modVersion, id: project.archivesBaseName, repo: modRepo, libname: libName, libver: libVer
}
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

apply plugin: "idea"

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}

repositories {
mavenCentral()
maven {
url 'https://jitpack.io'
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}

jar {
from "LICENSE"
}

// configure the maven publication
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/" + modRepo.toLowerCase())
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("PASSWORD")
}
}
// uncomment to publish to the local maven
// mavenLocal()
}
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
}
Loading