Skip to content

Commit

Permalink
Jitpack bs (#51)
Browse files Browse the repository at this point in the history
* jitpack

* typos

* try install instead of before install

* no CI

* publish?
  • Loading branch information
mitchej123 authored Jan 16, 2022
1 parent 03b6813 commit b1d6680
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 30 deletions.
115 changes: 87 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 928ecf7feb33a1149538b0e2cd17e3bc5f281428
//version: 1641429628
/*
DO NOT CHANGE THIS FILE!
Expand Down Expand Up @@ -32,7 +32,7 @@ buildscript {
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.5'
}
}

Expand All @@ -42,6 +42,7 @@ plugins {
id("org.ajoberstar.grgit") version("3.1.1")
id("com.github.johnrengelman.shadow") version("4.0.4")
id("com.palantir.git-version") version("0.12.3")
id("maven-publish")
}

apply plugin: 'forge'
Expand Down Expand Up @@ -194,7 +195,9 @@ if(file("addon.gradle").exists()) {
apply from: 'repositories.gradle'

configurations {
implementation.extendsFrom(shadowImplementation)
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
implementation.extendsFrom(shadowCompile)
implementation.extendsFrom(shadeCompile)
}

repositories {
Expand Down Expand Up @@ -260,16 +263,28 @@ task relocateShadowJar(type: ConfigureShadowRelocation) {
}

shadowJar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

manifest {
attributes(getManifestAttributes())
}

minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
dependsOn(relocateShadowJar)
}

jar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

manifest {
attributes(getManifestAttributes())
}
Expand Down Expand Up @@ -343,31 +358,31 @@ tasks.withType(JavaExec).configureEach {
}

processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// replace version and mcversion
expand "minecraftVersion": project.minecraft.version,
"modVersion": versionDetails().lastTag,
"modId": modId,
"modName": modName
}
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

if(usesMixins.toBoolean()) {
from refMap
}
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// replace version and mcversion
expand "minecraftVersion": project.minecraft.version,
"modVersion": versionDetails().lastTag,
"modId": modId,
"modName": modName
}

if(usesMixins.toBoolean()) {
from refMap
}

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}

def getManifestAttributes() {
def manifestAttributes = [:]
Expand Down Expand Up @@ -400,6 +415,12 @@ task sourcesJar(type: Jar) {
}

task shadowDevJar(type: ShadowJar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

from sourceSets.main.output
getArchiveClassifier().set("dev")

Expand All @@ -408,7 +429,7 @@ task shadowDevJar(type: ShadowJar) {
}

minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
}

task relocateShadowDevJar(type: ConfigureShadowRelocation) {
Expand All @@ -423,6 +444,12 @@ task circularResolverJar(type: Jar) {
}

task devJar(type: Jar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

from sourceSets.main.output
getArchiveClassifier().set("dev")

Expand Down Expand Up @@ -460,6 +487,38 @@ artifacts {
}
}

// publishing
publishing {
publications {
maven(MavenPublication) {
artifact source: jar
artifact source: sourcesJar, classifier: "src"
artifact source: devJar, classifier: "dev"
if (apiPackage) {
artifact source: apiJar, classifier: "api"
}

groupId = System.getenv("ARTIFACT_GROUP_ID") ?: group
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
version = System.getenv("ARTIFACT_VERSION") ?: project.version
}
}

repositories {
maven {
String owner = System.getenv("REPOSITORY_OWNER") ?: "Unknown"
String repositoryName = System.getenv("REPOSITORY_NAME") ?: "Unknown"
String githubRepositoryUrl = "https://maven.pkg.github.com/$owner/$repositoryName"
name = "GitHubPackages"
url = githubRepositoryUrl
credentials {
username = System.getenv("GITHUB_ACTOR") ?: "NONE"
password = System.getenv("GITHUB_TOKEN") ?: "NONE"
}
}
}
}

// Updating
task updateBuildScript {
doLast {
Expand Down
5 changes: 3 additions & 2 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
before_install:
- ./gradlew setupDecompWorkspace
install:
- ./gradlew setupDecompWorkspace build publishToMavenLocal

0 comments on commit b1d6680

Please sign in to comment.