Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyDev05 committed Jan 12, 2025
0 parents commit c10f7ac
Show file tree
Hide file tree
Showing 20 changed files with 1,159 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Gradle CI

on:
workflow_dispatch:
push:
branches: [ master ]
pull_request:
branches: [ master ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
validate:
uses: ./.github/workflows/wrapper-validation.yaml

build:
needs: validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- uses: gradle/gradle-build-action@v2
with:
arguments: :build

test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- uses: gradle/gradle-build-action@v2
with:
arguments: :test
9 changes: 9 additions & 0 deletions .github/workflows/wrapper-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Validate Gradle Wrapper
on: [workflow_call, pull_request]

jobs:
validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1.1.0
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!src/main/**/build/
!src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!src/main/**/out/
!src/test/**/out/

### Kotlin ###
.kotlin

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!src/main/**/bin/
!src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Julian Krings

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 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.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<h1 align="center">Libby Jar</h1>
<h3 align="center">Runtime Dependency Management</h3>
<div align="center">
<a href="https://github.com/CrazyDev05/libbyjar">
<img src="https://img.shields.io/github/license/CrazyDev05/libbyjar">
</a>
<a href="https://github.com/CrazyDev05/libbyjar/actions/workflows/gradle.yml">
<img src="https://github.com/CrazyDev05/libbyjar/actions/workflows/gradle.yml/badge.svg">
</a>
</div>

<hr>

<h4>What is Libbyjar?</h4>

LibbyJar allows you to easily include your gradle dependencies in your plugin with the help of <a href="https://github.com/AlessioDP/libby">libby</a>

<h2 align="center">Usage Example</h2>
<h4 align="center">Note: Use the shadowJar task to compile your project</h4>
<br><br>


```java
// this needs to be ran before you reference your dependencies
Libraries.load(new PaperLibraryManager(plugin));
```
(NOTE: If you have specified relocations and are running in a IDE or any environment that does not use the shadowjar-ed build file, use the `ignoreRelocation` flag while running by using `-DignoreRelocation` in your runner arguments)
*build.gradle.kts*
```kotlin
plugins {
id("com.gradleup.shadow") version "8.3.5"
id("de.crazydev22.libbyjar") version "1.0.0"
}
dependencies {
libby("group.id:artifact.id:version")
}

libbyJar {
relocate("a.b.c", "m.n.o")
packageName = "de.crazydev22.libbyjar"
className = "Libraries"

type = "paper"
version = "1.3.1"
}
```
96 changes: 96 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

plugins {
id("java-gradle-plugin")
id("com.gradle.plugin-publish") version "1.3.0"
id("com.gradleup.shadow") version "8.3.5"
kotlin("jvm") version "2.0.21"
}

group = "de.crazydev22"
version = "1.0.0"

repositories {
mavenCentral()
gradlePluginPortal()
maven("https://repo.alessiodp.com/releases/")
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:2.0.21")
implementation("net.byteflux:libby-core:1.3.1")

compileOnly(gradleApi())
compileOnly(gradleKotlinDsl())
compileOnly("com.gradleup.shadow:shadow-gradle-plugin:8.3.5")

testImplementation(kotlin("test"))
testImplementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.5")
testImplementation(gradleApi())
testImplementation(gradleKotlinDsl())
testImplementation(gradleTestKit())
}

kotlin {
jvmToolchain(21)
explicitApi()
}

val ensureDependenciesAreInlined by tasks.registering {
description = "Ensures all declared dependencies are inlined into shadowed jar"
group = HelpTasksPlugin.HELP_GROUP
dependsOn(tasks.shadowJar)

doLast {
val nonInlinedDependencies = mutableListOf<String>()
zipTree(tasks.shadowJar.flatMap { it.archiveFile }).visit {
if (!isDirectory) return@visit

val path = relativePath
if (
!path.startsWith("META-INF") &&
path.lastName.endsWith(".class") &&
!path.pathString.startsWith("de/crazydev22/libbyjar")
) nonInlinedDependencies.add(path.pathString)
}

if (nonInlinedDependencies.isEmpty()) return@doLast
throw GradleException("Found non inlined dependencies: $nonInlinedDependencies")
}
}

tasks {
named("check") {
dependsOn(ensureDependenciesAreInlined)
dependsOn(validatePlugins)
}

shadowJar {
archiveClassifier.set("")

mapOf(
"kotlin" to ".kotlin",
"org.intellij" to ".intellij",
"org.jetbrains" to ".jetbrains"
).forEach { relocate(it.key, "de.crazydev22.libbyjar${it.value}") }
}

test {
useJUnitPlatform()
}
}

@Suppress("UnstableApiUsage")
gradlePlugin {
website.set("https://github.com/CrazyDev05/LibbyJar")
vcsUrl.set("https://github.com/CrazyDev05/LibbyJar")

plugins {
create("libbyjar") {
id = "de.crazydev22.libbyjar"
displayName = "LibbyJar"
description = "JVM Runtime Dependency Management."
implementationClass = "de.crazydev22.libbyjar.LibbyJarPlugin"
tags.set(listOf("runtime dependency", "relocation"))
}
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Wed Jan 01 03:12:36 CET 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit c10f7ac

Please sign in to comment.