Skip to content

Commit 6a20037

Browse files
Felix KleinekathöferdualspiralZidane
authored
2.0.0-M2.5 (#1049)
* Update for plugin-meta 0.8.0 for API 8 meta changes (#1043) * Update for plugin-meta 0.8.0 for API 8 meta changes * Fix for scalafmt * Once more, with feeling... * Don't return a partially created data value seq if an error was thrown * Move to the 0.8.0 release * Update for comments Co-authored-by: Chris Sanders <zidane@spongepowered.org> * plugins.json -> sponge_plugins.json Forgot to update this... * Ensure input streams are not closed when finding meta files (#1045) * Ensure input streams are not closed when finding meta files plugin-meta 0.8 closes streams when it's read the metadata. We override the close() method to prevent that from happening. * Formatting * I'll get this right * Work around recommended version not being a restriction for deps (#1046) * Removed triplequote (#1047) * Removed triplequote * Delete triplequote_black.svg * Delete triplequote_white.svg * Update README.md * Update Settings.scala (#1048) Co-authored-by: Daniel Naylor <1904167+dualspiral@users.noreply.github.com> Co-authored-by: Chris Sanders <zidane@spongepowered.org>
1 parent 6d62a7e commit 6a20037

10 files changed

Lines changed: 53 additions & 146 deletions

File tree

README.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,3 @@ For `jobs`:
6262
more stack size to sbt in the way you're starting sbt. `-Xss4m` should be enough. If you're using IntelliJ, you can set
6363
this in the VM arguments field. If you're invoking sbt directly, the most common ways to set this is either through
6464
the `SBT_OPTS` environment variable, or with a file named `.jvmopts` with each flag on a new line.
65-
66-
### Using Hydra
67-
68-
Hydra is the world’s only parallel compiler for the Scala language.
69-
Its design goal is to take advantage of the many cores available in modern hardware to parallelize compilation of Scala sources.
70-
This gives us the possibility to achieve a much faster compile time.
71-
[Triplequote](https://triplequote.com/) has kindly provided us with some licenses.
72-
If you have a license and want to use Hydra, follow these steps:
73-
74-
1. Create the file `project/hydra.sbt`
75-
2. Put in this content into the newly created file:
76-
```
77-
credentials += Credentials("Artifactory Realm",
78-
"repo.triplequote.com",
79-
"<username>",
80-
"<password>")
81-
resolvers += Resolver.url("Triplequote Plugins Releases", url("https://repo.triplequote.com/artifactory/sbt-plugins-release/"))(Resolver.ivyStylePatterns)
82-
addSbtPlugin("com.triplequote" % "sbt-hydra" % "<version>")
83-
```
84-
- The `<username>` and `<password>` placeholders have to be replaced with your credentials.
85-
- The `<version>` placeholder has to be replaced with the lastest version of `sbt-hydra` which can be obtained from the [offical changelog](https://docs.triplequote.com/changelog/).
86-
87-
3. Open the sbt console and make use of the following command where `<license key>` is your personal hydra license key:
88-
89-
```
90-
hydraActivateLicense <license key>
91-
```
92-
93-
4. Go and start compiling!
94-
95-
Further instructions can be found at the [official Hydra documentation](https://docs.triplequote.com/).

apiV2/app/models/querymodels/apiV2QueryModels.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ object APIV2QueryProject {
167167
//This will crash and burn if the implementation becomes
168168
//something else, but better that, than failing silently
169169
case version: DefaultArtifactVersion =>
170-
if (BigInt(version.getVersion.getFirstInteger) >= 28) {
170+
if (BigInt(version.version.getFirstInteger) >= 28) {
171171
Some(version.toString) //Not sure what we really want to do here
172172
} else {
173173
version.toString match {

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ lazy val orePlayCommon: Project = project
9797
libraryDependencies ++= Seq(caffeine, ws),
9898
libraryDependencies ++= Seq(
9999
Deps.pluginMeta,
100+
Deps.pluginMetaMcMod,
100101
Deps.slickPlay,
101102
Deps.zio,
102103
Deps.zioCats,

ore/conf/ore-default-settings.conf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,6 @@ sponge {
243243
"image": "images/sponsors/creeperhost.svg",
244244
"link": "https://billing.creeperhost.net/link.php?id=8"
245245
},
246-
{
247-
"name": "Triplequote",
248-
"image": "images/sponsors/triplequote_black.svg",
249-
"link": "https://triplequote.com/hydra"
250-
},
251246
{
252247
"name": "JetBrains",
253248
"image": "images/sponsors/jetbrains.svg",

ore/public/images/sponsors/triplequote_black.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

ore/public/images/sponsors/triplequote_white.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

orePlayCommon/app/ore/models/project/io/PluginFile.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ class PluginFile(val path: Path, val user: Model[User]) {
4949
.continually(jarIn.getNextJarEntry)
5050
.takeWhile(_ != null) // scalafix:ok
5151
.filter(entry => fileNames.contains(entry.getName))
52-
.flatMap(entry => PluginFileData.getData(entry.getName, new BufferedReader(new InputStreamReader(jarIn))))
52+
.flatMap { entry =>
53+
PluginFileData.getData(entry.getName, new BufferedReader(new InputStreamReader(jarIn)) {
54+
override def close(): Unit = {}
55+
})
56+
}
5357
.toVector
5458

5559
// Mainfest file isn't read in the jar stream for whatever reason

orePlayCommon/app/ore/models/project/io/PluginFileData.scala

Lines changed: 40 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
package ore.models.project.io
22

33
import scala.language.higherKinds
4-
54
import java.io.BufferedReader
6-
import com.google.gson.stream.JsonReader
75

86
import scala.collection.mutable.ArrayBuffer
97
import scala.jdk.CollectionConverters._
8+
import scala.jdk.OptionConverters._
109
import scala.util.control.NonFatal
11-
1210
import ore.data.project.Dependency
1311
import ore.db.{DbRef, Model, ModelService}
1412
import ore.models.project.{TagColor, Version, VersionTag}
15-
1613
import org.spongepowered.plugin.meta.McModInfo
14+
import org.spongepowered.plugin.metadata.builtin.MetadataParser
15+
import org.spongepowered.plugin.metadata.model.PluginDependency
1716

1817
/**
1918
* The metadata within a [[PluginFile]]
@@ -155,26 +154,26 @@ object McModInfoHandler extends FileTypeHandler("mcmod.info") {
155154
else {
156155
val metadata = info.head
157156

158-
if (metadata.getId != null)
159-
dataValues += StringDataValue("id", metadata.getId)
157+
if (metadata.id != null)
158+
dataValues += StringDataValue("id", metadata.id)
160159

161-
if (metadata.getVersion != null)
162-
dataValues += StringDataValue("version", metadata.getVersion)
160+
if (metadata.version != null)
161+
dataValues += StringDataValue("version", metadata.version)
163162

164-
if (metadata.getName != null)
165-
dataValues += StringDataValue("name", metadata.getName)
163+
if (metadata.name != null)
164+
dataValues += StringDataValue("name", metadata.name)
166165

167-
if (metadata.getDescription != null)
168-
dataValues += StringDataValue("description", metadata.getDescription)
166+
if (metadata.description != null)
167+
dataValues += StringDataValue("description", metadata.description)
169168

170-
if (metadata.getUrl != null)
171-
dataValues += StringDataValue("url", metadata.getUrl)
169+
if (metadata.url != null)
170+
dataValues += StringDataValue("url", metadata.url)
172171

173-
if (metadata.getAuthors != null)
174-
dataValues += StringListValue("authors", metadata.getAuthors.asScala.toSeq)
172+
if (metadata.authors != null)
173+
dataValues += StringListValue("authors", metadata.authors.asScala.toSeq)
175174

176-
if (metadata.getDependencies != null) {
177-
val dependencies = metadata.getDependencies.asScala.map(p => Dependency(p.getId, Option(p.getVersion))).toSeq
175+
if (metadata.dependencies != null) {
176+
val dependencies = metadata.dependencies.asScala.map(p => Dependency(p.id, Option(p.version()))).toSeq
178177
dataValues += DependencyDataValue("dependencies", dependencies)
179178
}
180179

@@ -209,98 +208,35 @@ object ModTomlHandler extends FileTypeHandler("mod.toml") {
209208
Nil
210209
}
211210

212-
object SpongeJsonHandler extends FileTypeHandler("META-INF/plugins.json") {
213-
214-
def readDependencies(in: JsonReader) = {
215-
val deps = new ArrayBuffer[Dependency]
216-
in.beginArray()
217-
while (in.hasNext) {
218-
in.beginObject()
219-
var dep = Dependency(null, None)
220-
while (in.hasNext) {
221-
in.nextName() match {
222-
case "id" => dep = dep.copy(pluginId = in.nextString())
223-
case "version" => dep = dep.copy(version = Option(in.nextString()))
224-
case _ => in.skipValue()
225-
}
226-
}
227-
deps += dep
228-
in.endObject()
229-
}
230-
in.endArray()
231-
deps.toSeq
232-
}
233-
234-
def readAuthors(in: JsonReader) = {
235-
val authors = new ArrayBuffer[String]
236-
in.beginArray()
237-
while (in.hasNext) {
238-
in.beginObject()
239-
while (in.hasNext) {
240-
in.nextName() match {
241-
case "name" => authors += in.nextString()
242-
case _ => in.skipValue()
243-
}
244-
}
245-
in.endObject()
246-
}
247-
in.endArray()
248-
authors.toSeq
249-
}
250-
251-
def readDataValue(dvs: ArrayBuffer[DataValue], in: JsonReader) = {
252-
while (in.hasNext) {
253-
in.nextName() match {
254-
case "id" => dvs += StringDataValue("id", in.nextString());
255-
case "version" => dvs += StringDataValue("version", in.nextString());
256-
case "name" => dvs += StringDataValue("name", in.nextString());
257-
case "description" => dvs += StringDataValue("description", in.nextString());
258-
case "contributors" => dvs += StringListValue("authors", readAuthors(in));
259-
case "dependencies" => dvs += DependencyDataValue("dependencies", readDependencies(in));
260-
// case "links" =>
261-
// case "main-class" =>
262-
// case "loader" =>
263-
case _ => in.skipValue() // ignored
264-
}
265-
266-
}
267-
}
268-
269-
def readDataValues(dvs: ArrayBuffer[DataValue], in: JsonReader): Unit = {
270-
var first = true;
271-
in.beginArray()
272-
while (in.hasNext) {
273-
if (first) {
274-
in.beginObject()
275-
readDataValue(dvs, in)
276-
first = false;
277-
in.endObject()
278-
} else {
279-
in.skipValue() // cannot handle multiple plugins for now
280-
}
281-
}
282-
in.endArray()
283-
}
211+
object SpongeJsonHandler extends FileTypeHandler("META-INF/sponge_plugins.json") {
284212

285213
override def getData(bufferedReader: BufferedReader): Seq[DataValue] = {
286-
val dataValues = new ArrayBuffer[DataValue]
287214
try {
288-
val reader = new JsonReader(bufferedReader)
289-
reader.beginObject()
290-
try {
291-
if (reader.hasNext) {
292-
if (reader.nextName().equals("plugins")) {
293-
readDataValues(dataValues, reader)
294-
}
295-
}
296-
} finally {
297-
reader.endObject()
298-
}
299-
dataValues.toSeq
215+
val metadata = MetadataParser.read(bufferedReader)
216+
val firstPlugin = metadata.metadata.asScala.head
217+
Seq[DataValue](
218+
StringDataValue("id", firstPlugin.id),
219+
StringDataValue("version", firstPlugin.version.toString),
220+
StringListValue("authors", firstPlugin.contributors.asScala.map(_.name).toSeq),
221+
DependencyDataValue("dependencies", readDependencies(firstPlugin.dependencies.asScala))
222+
) ++ Seq(
223+
firstPlugin.name.toScala.map(v => StringDataValue("name", v)),
224+
firstPlugin.description.toScala.map(v => StringDataValue("description", v))
225+
).flatten
300226
} catch {
301-
case NonFatal(e) =>
227+
case NonFatal(e) => {
302228
e.printStackTrace()
303229
Nil
230+
}
304231
}
305232
}
233+
234+
def readDependencies(in: Iterable[PluginDependency]): Seq[Dependency] =
235+
in.map { dep =>
236+
Dependency(
237+
dep.id,
238+
Option.when(dep.version.hasRestrictions || dep.version.getRecommendedVersion != null)(dep.version.toString)
239+
)
240+
}.toSeq
241+
306242
}

project/Settings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object Settings {
1111
val scalaVer = "2.13.6"
1212

1313
val commonSettings = Seq(
14-
version := "2.0.0-M2.4",
14+
version := "2.0.0-M2.5",
1515
scalaVersion := scalaVer,
1616
scalacOptions ++= Seq(
1717
"-deprecation",

project/dependencies.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ object Deps {
9090
"ext-wikilink"
9191
).map(flexmarkDep)
9292

93-
val pluginMeta = "org.spongepowered" % "plugin-meta" % "0.4.1"
93+
// Sponge API-8+
94+
val pluginMeta = "org.spongepowered" % "plugin-meta" % "0.8.0"
95+
96+
// mcmod.info
97+
val pluginMetaMcMod = "org.spongepowered.plugin-meta" % "mcmod-info" % "0.8.0"
9498

9599
val javaxMail = "javax.mail" % "mail" % "1.4.7"
96100
val postgres = "org.postgresql" % "postgresql" % "42.2.16"

0 commit comments

Comments
 (0)