Skip to content

Commit 8a7707b

Browse files
committed
Initial commit
As of right now, GitVersion is mostly a port of the Git utilities from GradleUtils and SharedActions. This is to ensure that the versioning system is consistent across all Forge projects. While not directly credited as co-authors, GitVersion was built off of the work done in GradleUtils and SharedActions by LexManos and prior Forge contributors.
0 parents  commit 8a7707b

26 files changed

+2968
-0
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text eol=lf
2+
*.bat text eol=crlf
3+
*.java text eol=lf
4+
*.gradle text eol=crlf

.github/workflows/publish.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main
13+
with:
14+
java: 17
15+
gradle_tasks: "publish"
16+
artifact_name: "git-version"
17+
secrets:
18+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
19+
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}
20+
PROMOTE_ARTIFACT_USERNAME: ${{ secrets.PROMOTE_ARTIFACT_USERNAME }}
21+
PROMOTE_ARTIFACT_PASSWORD: ${{ secrets.PROMOTE_ARTIFACT_PASSWORD }}
22+
MAVEN_USER: ${{ secrets.MAVEN_USER }}
23+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**/.gradle/
2+
/**/.classpath
3+
/**/.project
4+
/**/.settings/
5+
/**/bin/
6+
/**/test/
7+
/**/build/
8+
/repo/
9+
/cache/
10+
/_old_mdks_/
11+
12+
# Tool Output - Jonathan uses the run directory
13+
/run/
14+
/output/
15+
16+
# Jonathan's IntelliJ Fuckery
17+
/.idea/

LICENSE-header.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Copyright (c) Forge Development LLC
2+
SPDX-License-Identifier: LGPL-2.1-only

LICENSE.txt

Lines changed: 502 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Git Version
2+
3+
GitVersion is a framework-agnostic implementation of Git-based versioning using the JGit library. While primarily
4+
designed for Java projects within the Minecraft Forge organization, it can be used anywhere as a command-line tool or in
5+
a Gradle project, with a default implementation available in [GradleUtils](https://github.com/MinecraftForge/GradleUtils).
6+
7+
> [!CAUTION]
8+
> **GitVersion is still very early in development!** Nothing is set in stone, and many things may change in the future.
9+
> It is currently a port of features from GradleUtils 2.3 and SharedActions, with some additional utilities added in
10+
> as part of the command-line tool.
11+
12+
## Usage as a Command-Line Tool
13+
14+
GitVersion can be used as a command-line tool to generate version numbers and changelogs. You can learn more about
15+
its usage by running it with the help command:
16+
```bash
17+
java -jar git-version-0.0.0-fatjar.jar --help
18+
```
19+
20+
An important thing to note about GitVersion is that it is designed to save a config file every time it is run unless the
21+
`--do-not-save` flag is passed. This config file is used to store the tag prefix, match filters, marker file names,
22+
ignore file names, and ignored directories. This is so that CI agents are able to run GitVersion without needing to pass
23+
these arguments manually within their configurations.
24+
25+
## Usage in a Gradle buildscript
26+
27+
As of right now, GitVersion does not have a dedicated plugin for Gradle buildscripts. However, a default implementation
28+
exists within GradleUtils 2.4 and newer. You can find more details on GradleUtils itself, but here is a basic example of
29+
its usage in a Gradle buildscript:
30+
31+
```groovy
32+
gradleutils.version.tagPrefix = '1.21.4-'
33+
gradleutils.version.matchFilter = '1.*.4.*'
34+
35+
version = gradleutils.version.tagOffsetVersion
36+
```

build.gradle

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
plugins {
2+
id 'java-library'
3+
id 'idea'
4+
id 'maven-publish'
5+
id 'net.minecraftforge.licenser' version '1.1.1'
6+
id 'net.minecraftforge.gradleutils' version '2.3.6'
7+
id 'com.gradleup.shadow' version '8.3.6'
8+
}
9+
10+
group = 'net.minecraftforge'
11+
version = gradleutils.tagOffsetVersion
12+
println "Version: $version"
13+
14+
java {
15+
toolchain.languageVersion = JavaLanguageVersion.of(17)
16+
withSourcesJar()
17+
}
18+
19+
repositories {
20+
maven { url = 'https://repo.eclipse.org/content/groups/releases/' }
21+
mavenCentral()
22+
}
23+
24+
configurations {
25+
shadowOnly {
26+
canBeResolved = true
27+
canBeConsumed = false
28+
}
29+
}
30+
31+
dependencies {
32+
// Git
33+
api libs.eclipse.jgit
34+
35+
// Command Line
36+
shadowOnly libs.slf4j
37+
shadowOnly libs.jopt
38+
compileOnly libs.jopt
39+
40+
// Utilities
41+
implementation libs.gson
42+
implementation libs.commons.io
43+
44+
// Static Analysis
45+
compileOnly libs.nulls
46+
}
47+
48+
license {
49+
header = file('LICENSE-header.txt')
50+
newLine = false
51+
exclude '**/*.properties'
52+
}
53+
54+
jar {
55+
manifest {
56+
attributes([
57+
'Specification-Title' : 'Git Version',
58+
'Specification-Vendor' : 'Forge Development LLC',
59+
'Specification-Version' : gradleutils.gitInfo.tag,
60+
'Implementation-Title' : 'Git Version',
61+
'Implementation-Vendor' : 'Forge Development LLC',
62+
'Implementation-Version': project.version
63+
] as LinkedHashMap, 'net/minecraftforge/gitver/')
64+
}
65+
66+
exclude('net/minecraftforge/gitver/Main.class')
67+
}
68+
69+
tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar).configure {
70+
manifest {
71+
attributes([
72+
'Main-Class': 'net.minecraftforge.gitver.Main'
73+
] as LinkedHashMap)
74+
}
75+
76+
configurations = [project.configurations.runtimeClasspath, project.configurations.shadowOnly]
77+
archiveClassifier = 'fatjar'
78+
minimize()
79+
}
80+
81+
artifacts {
82+
archives shadowJar
83+
}
84+
85+
changelog {
86+
fromBase()
87+
publishAll = false
88+
}
89+
90+
publishing {
91+
publications.register('mavenJava', MavenPublication) {
92+
from components.java
93+
94+
artifactId = 'git-version'
95+
changelog.publish(it)
96+
97+
pom {
98+
name = 'Git Version'
99+
description = 'Used by MinecraftForge projects to calculate project versions based on git history'
100+
url = 'https://github.com/MinecraftForge/GitVersion'
101+
102+
gradleutils.pom.setGitHubDetails(pom, 'GitVersion')
103+
104+
license gradleutils.pom.licenses.LGPLv2_1
105+
106+
developers {
107+
developer {
108+
id = 'Jonathing'
109+
name = 'Jonathing'
110+
111+
url = 'https://jonathing.me'
112+
timezone = 'America/New_York'
113+
}
114+
}
115+
}
116+
}
117+
118+
repositories {
119+
maven gradleutils.publishingForgeMaven
120+
}
121+
}
122+
123+
idea.module { downloadSources = downloadJavadoc = true }

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.gradle.caching=true
2+
org.gradle.parallel=true
3+
org.gradle.configuration-cache=true
4+
org.gradle.configureondemand=true

gradle/wrapper/gradle-wrapper.jar

42.6 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)