Skip to content

Commit

Permalink
[Change] Gradle + Publishing Data
Browse files Browse the repository at this point in the history
  • Loading branch information
CDAGaming committed Dec 31, 2023
1 parent 1bccd0a commit c189494
Show file tree
Hide file tree
Showing 11 changed files with 541 additions and 104 deletions.
18 changes: 18 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
* text=auto eol=lf
*.java text eol=lf
*.groovy text eol=lf
*.scala text eol=lf
*.sh text eol=lf
*.bat text eol=crlf
*.md text
*.properties text

*.dat binary
*.bin binary
*.png binary
*.exe binary
*.dll binary
*.zip binary
*.jar binary
*.7z binary
*.db binary
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- run: chmod +x gradlew
- run: ./gradlew --version --no-daemon
- run: ./gradlew build shadowJar --stacktrace --no-daemon --console=plain --warning-mode all
- uses: actions/upload-artifact@v3
with:
name: artifacts
path: build/libs/*.jar
11 changes: 11 additions & 0 deletions .github/workflows/validate-gradle-wrapper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Validate Gradle Wrapper

on: [push, pull_request]

jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
44 changes: 16 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
# Compiled class file
*.class
#General
/repo
/.gradle
/build

# Log file
*.log
#Eclipse
.settings
.metadata
.classpath
.project
/bin

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Intellij Project Files
/.idea/
/out/
#IntelliJ Idea
/out
/.idea
*.iml

# Testing
/src/test/
/target/
*.iws
*.ipr
s101plugin.state
127 changes: 127 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
plugins {
id 'java'
id 'signing'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

version = '0.6.0'
group = 'io.github.CDAGaming'
description = 'Connect locally to the Discord client using IPC for a subset of RPC features like Rich Presence and Activity Join/Spectate'
archivesBaseName = 'DiscordIPC'

sourceCompatibility = 1.8
targetCompatibility = 1.8

configurations {
shadeOnly
shade
implementation.extendsFrom shade
}

repositories {
mavenCentral()
}

dependencies {
shade group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
shade group: 'org.slf4j', name: 'slf4j-api', version: '2.0.10'
shade group: 'com.kohlschutter.junixsocket', name: 'junixsocket-common', version: '2.8.3'
shade group: 'com.kohlschutter.junixsocket', name: 'junixsocket-native-common', version: '2.8.3'
shade group: 'net.lenni0451', name: 'Reflect', version: '1.3.2'
}

jar.manifest.mainAttributes([
'Implementation-Title' : project.name,
'Implementation-Version': project.version
])

shadowJar {
configurations = [project.configurations.shade, project.configurations.shadeOnly]
archiveClassifier.set('')
exclude 'META-INF/versions/**'
}

tasks.register('javadocJar', Jar) {
dependsOn javadoc
from javadoc.destinationDir
archiveClassifier.set('javadoc')
}

tasks.register('sourcesJar', Jar) {
from sourceSets.main.allSource
archiveClassifier.set('sources')
}

artifacts {
archives jar
archives javadocJar
archives sourcesJar
}

assemble.dependsOn javadocJar, sourcesJar

[compileJava].each {
it.options.encoding = 'UTF-8'
it.options.deprecation = true
it.options.fork = true
}

publishing {
publications {
mavenJava(MavenPublication) {
artifact shadowJar
artifact javadocJar
artifact sourcesJar

pom {
name = archivesBaseName
artifactId = archivesBaseName
packaging = 'jar'
description = project.description
url = 'https://github.com/CDAGaming/DiscordIPC'

scm {
connection = 'scm:git:git://github.com/CDAGaming/DiscordIPC.git'
developerConnection = 'scm:git:ssh://github.com/CDAGaming/DiscordIPC.git'
url = 'https://github.com/CDAGaming/DiscordIPC'
}
licenses {
license {
name = 'Apache License 2.0'
url = 'https://github.com/CDAGaming/DiscordIPC/blob/master/LICENSE'
}
}
developers {
developer {
id = 'cdagaming'
name = 'CDAGaming'
email = '[email protected]'
}
developer {
id = 'jagrosh'
name = 'John Grosh'
email = '[email protected]'
}
}
}
}
}
repositories {
maven {
credentials {
username = System.getenv("OSSRH_USERNAME") // echo %OSSRH_USERNAME% / Create a system environment variable with your sonatype login username
password = System.getenv("OSSRH_PASSWORD") // echo %OSSRH_PASSWORD% / Create a system environment variable with your sonatype login password
}

def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('-SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}

signing {
useGpgCmd()
sign publishing.publications.mavenJava
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit c189494

Please sign in to comment.