Use Self-Hosted Maven
ScriptCraft/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-04-29 14:56:51 -04:00
parent 7da36aa083
commit e1f486a750
20 changed files with 326 additions and 23 deletions

4
Jenkinsfile vendored
View File

@ -1,6 +1,8 @@
pipeline {
agent {
dockerfile true
dockerfile {
args '-v /data/maven:/data/maven'
}
}
stages {
stage('Setup') {

View File

@ -1,6 +1,6 @@
plugins {
id 'fabric-loom' version '0.2.7-SNAPSHOT'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'maven-publish'
}
compileJava {
@ -62,27 +62,20 @@ jar {
from 'LICENSE'
}
if (project.hasProperty('curseforge.api_key')) {
curseforge {
apiKey = project.getProperty('curseforge.api_key')
project {
id = project.curseforge_id
changelog = 'A changelog can be found at https://gitea.thebrokenrail.com/TheBrokenRail/ScriptCraft/src/branch/master/CHANGELOG.md'
releaseType = 'release'
addGameVersion project.simple_minecraft_version
addGameVersion 'Fabric'
mainArtifact(remapJar) {
displayName = "ScriptCraft v${mod_version} for ${project.minecraft_version}"
publishing {
publications {
mavenJava(MavenPublication) {
artifact(remapJar) {
builtBy remapJar
}
afterEvaluate {
uploadTask.dependsOn('remapJar')
}
relations {
requiredDependency 'fabric-api'
artifact(typescriptAPI) {
builtBy typescriptAPI
}
}
options {
forgeGradleIntegration = false
}
repositories {
maven {
url '/data/maven'
}
}
}

28
examples/typescript/.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
# gradle
.gradle/
build/
out/
classes/
# idea
.idea/
*.iml
*.ipr
*.iws
# vscode
.settings/
bin/
.classpath
.project
# fabric
run/
remappedSrc/
libs/

View File

@ -0,0 +1,68 @@
plugins {
id 'fabric-loom' version '0.2.7-SNAPSHOT'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
archivesBaseName = project.archives_base_name
def mod_version = project.mod_version as Object
version = "${mod_version}+${project.minecraft_version}"
group = project.maven_group as Object
minecraft {
}
repositories {
flatDir {
dirs 'libs'
}
}
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.fabric_loader_version}"
modImplementation name: 'scriptcraft'
}
apply from: './typescript.build.gradle'
processResources {
inputs.property 'version', mod_version
from(sourceSets.main.resources.srcDirs) {
include 'fabric.mod.json'
expand 'version': mod_version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'fabric.mod.json'
}
}
// 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'
}
// 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
}
artifacts {
archives sourcesJar
}
jar {
from 'LICENSE'
}

1
examples/typescript/gradle Symbolic link
View File

@ -0,0 +1 @@
../../gradle

View File

@ -0,0 +1,13 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs = -Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version = 1.15.2
yarn_build = 15
fabric_loader_version = 0.8.2+build.194
# Mod Properties
mod_version = 1.0.0
maven_group = com.thebrokenrail
archives_base_name = scriptcraft-typescript-example

1
examples/typescript/gradlew vendored Symbolic link
View File

@ -0,0 +1 @@
../../gradlew

1
examples/typescript/gradlew.bat vendored Symbolic link
View File

@ -0,0 +1 @@
../../gradlew.bat

View File

@ -0,0 +1,16 @@
#!/bin/sh
set -e
SCRIPTCRAFT_BRANCH='master'
if [ -d ../libs ]; then
rm -rf ../libs
fi
mkdir ../libs
curl -L -o ../libs/scriptcraft.jar "https://jenkins.thebrokenrail.com/job/ScriptCraft/job/${SCRIPTCRAFT_BRANCH}/lastSuccessfulBuild/artifact/build/libs/scriptcraft-1.0.0-SNAPSHOT.jar"
curl -L -o ../libs/scriptcraft-api.tar.gz "https://jenkins.thebrokenrail.com/job/ScriptCraft/job/${SCRIPTCRAFT_BRANCH}/lastSuccessfulBuild/artifact/build/distributions/scriptcraft-1.0.0-SNAPSHOT-api.tar.gz"
cd ../src/main/ts
npm install

View File

@ -0,0 +1 @@
../../settings.gradle

View File

@ -0,0 +1,15 @@
package com.thebrokenrail.scriptcraft.example;
import com.thebrokenrail.scriptcraft.core.ScriptCraftEntrypoint;
public class TypeScriptExample implements ScriptCraftEntrypoint {
@Override
public String getModID() {
return "modid";
}
@Override
public String getModIndex() {
return "index.js";
}
}

View File

@ -0,0 +1 @@
../../../../../src/main/resources/assets

View File

@ -0,0 +1,28 @@
{
"schemaVersion": 1,
"id": "modid",
"version": "${version}",
"name": "ScriptCraft TypeScript Example",
"description": "TypeScript Example for ScriptCraft",
"authors": [
"TheBrokenRail"
],
"contact": {
"homepage": "https://thebrokenrail.com/",
"sources": "https://gitea.thebrokenrail.com/TheBrokenRail/ScriptCraft.git",
"issues": "https://gitea.thebrokenrail.com/TheBrokenRail/ScriptCraft/issues"
},
"license": "MIT",
"icon": "assets/scriptcraft/icon.png",
"environment": "*",
"entrypoints": {
"scriptcraft": [
"com.thebrokenrail.scriptcraft.example.TypeScriptExample"
]
},
"depends": {
"fabricloader": ">=0.7.4",
"minecraft": "1.15.x",
"scriptcraft": "*"
}
}

View File

@ -0,0 +1,4 @@
node_modules/
package-lock.json
scriptcraft/
lib/

View File

@ -0,0 +1,11 @@
{
"devDependencies": {
"typescript": "latest"
},
"dependencies": {
"scriptcraft-api": "file:../../../libs/scriptcraft-api.tar.gz"
},
"scripts": {
"build": "tsc"
}
}

View File

@ -0,0 +1,73 @@
import { BlockSettings, Identifier, Registry, BlockState, ActionResult, World, Pos, Hand, PlayerEntity, BlockItem, ItemSettings, CustomItem, Direction, LivingEntity, CustomBlockWithEntity, CustomBlockEntity, CompoundTag, NumberType } from 'minecraft';
console.log('hello');
class MyBlockEntity extends CustomBlockEntity {
ticks = 0;
toTag(tag: CompoundTag): CompoundTag {
tag.set('MyTicks', this.ticks, NumberType.INT);
return tag;
}
fromTag(tag: CompoundTag): void {
const obj = tag.get('MyTicks');
if (typeof obj === 'number') {
this.ticks = obj;
} else {
this.ticks = 0;
}
}
tick(): void {
this.ticks++;
this.markDirty();
}
}
class MyBlock extends CustomBlockWithEntity {
constructor() {
super(new BlockSettings('STONE', 'IRON'));
}
onUse(world: World, blockState: BlockState, blockPos: Pos, side: Direction, player: PlayerEntity, hand: Hand): ActionResult {
const entity = world.getCustomBlockEntity(blockPos);
if (entity instanceof MyBlockEntity) {
console.log('Ticks: ' + entity.ticks);
}
world.setBlockState(blockPos.offset(side), BlockState.getDefaultState(new Identifier('minecraft:stone')));
return ActionResult.SUCCESS;
}
createBlockEntity(): CustomBlockEntity {
return new MyBlockEntity();
}
}
Registry.register(Registry.BLOCK, new Identifier('test', 'my_block'), new MyBlock());
Registry.register(Registry.ITEM, new Identifier('test', 'my_block'), new BlockItem(new Identifier('test', 'my_block'), new ItemSettings()));
class MyItem extends CustomItem {
constructor() {
super(new ItemSettings().setItemGroup('building_blocks').setMaxCount(128));
}
onUse(world: World, player: PlayerEntity, hand: Hand): ActionResult {
console.log('Item Use: Normal');
return ActionResult.SUCCESS;
}
onUseOnBlock(world: World, blockPos: Pos, side: Direction, player: PlayerEntity, hand: Hand): ActionResult {
console.log('Item Use: Block ' + blockPos.toString());
world.spawnEntity(new Identifier('minecraft:cow'), blockPos.offset(side).add(new Pos(0.5, 0, 0.5))).toString();
return ActionResult.SUCCESS;
}
onUseOnEntity(player: PlayerEntity, target: LivingEntity, hand: Hand): ActionResult {
console.log('Item Use: Entity ' + target.toTag().toString());
console.log('Health: ' + target.toTag().get('Health').toString());
return ActionResult.SUCCESS;
}
}
Registry.register(Registry.ITEM, new Identifier('test', 'my_item'), new MyItem());

View File

@ -0,0 +1,21 @@
{
"compilerOptions": {
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"lib": ["es2020"],
"module": "es2020",
"target": "es2020",
"typeRoots": ["node_modules/scriptcraft-api/types"],
"rootDir": "src",
"baseUrl": "src",
"paths": {
"minecraft": ["../node_modules/scriptcraft-api/lib/minecraft/index.d.ts"]
},
"outDir": "lib/ts"
},
"include": [
"src/**/*.ts"
]
}

View File

@ -0,0 +1,29 @@
def typescriptRoot = 'src/main/ts'
def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
def typescriptOut = new File(typescriptRootFile, 'lib/ts')
task typescript(group: 'typescript', type: Exec) {
inputs.dir typescriptRootFile
outputs.dirs typescriptOut
workingDir typescriptRootFile
executable 'npm'
args 'run', 'build'
doFirst {
project.delete {
delete typescriptOut
}
}
}
processResources.dependsOn typescript
processResources {
from(typescriptOut.absolutePath) {
into 'scriptcraft'
}
}

View File

@ -4,8 +4,6 @@ org.gradle.jvmargs = -Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version = 1.15.2
curseforge_id = TBD
simple_minecraft_version = 1.15.2
yarn_build = 15
fabric_loader_version = 0.8.2+build.194

View File

@ -1,7 +1,6 @@
{
"name": "minecraft",
"version" : "1.0.0-SNAPSHOT",
"types": "lib/minecraft/index.d.ts",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "latest",