Skip to content

Commit

Permalink
2.0.0-M2.5 (#1049)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people committed Sep 6, 2021
1 parent 6d62a7e commit 6a20037
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 146 deletions.
31 changes: 0 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,3 @@ For `jobs`:
more stack size to sbt in the way you're starting sbt. `-Xss4m` should be enough. If you're using IntelliJ, you can set
this in the VM arguments field. If you're invoking sbt directly, the most common ways to set this is either through
the `SBT_OPTS` environment variable, or with a file named `.jvmopts` with each flag on a new line.

### Using Hydra

Hydra is the world’s only parallel compiler for the Scala language.
Its design goal is to take advantage of the many cores available in modern hardware to parallelize compilation of Scala sources.
This gives us the possibility to achieve a much faster compile time.
[Triplequote](https://triplequote.com/) has kindly provided us with some licenses.
If you have a license and want to use Hydra, follow these steps:

1. Create the file `project/hydra.sbt`
2. Put in this content into the newly created file:
```
credentials += Credentials("Artifactory Realm",
"repo.triplequote.com",
"<username>",
"<password>")
resolvers += Resolver.url("Triplequote Plugins Releases", url("https://repo.triplequote.com/artifactory/sbt-plugins-release/"))(Resolver.ivyStylePatterns)
addSbtPlugin("com.triplequote" % "sbt-hydra" % "<version>")
```
- The `<username>` and `<password>` placeholders have to be replaced with your credentials.
- 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/).

3. Open the sbt console and make use of the following command where `<license key>` is your personal hydra license key:

```
hydraActivateLicense <license key>
```

4. Go and start compiling!

Further instructions can be found at the [official Hydra documentation](https://docs.triplequote.com/).
2 changes: 1 addition & 1 deletion apiV2/app/models/querymodels/apiV2QueryModels.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ object APIV2QueryProject {
//This will crash and burn if the implementation becomes
//something else, but better that, than failing silently
case version: DefaultArtifactVersion =>
if (BigInt(version.getVersion.getFirstInteger) >= 28) {
if (BigInt(version.version.getFirstInteger) >= 28) {
Some(version.toString) //Not sure what we really want to do here
} else {
version.toString match {
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ lazy val orePlayCommon: Project = project
libraryDependencies ++= Seq(caffeine, ws),
libraryDependencies ++= Seq(
Deps.pluginMeta,
Deps.pluginMetaMcMod,
Deps.slickPlay,
Deps.zio,
Deps.zioCats,
Expand Down
5 changes: 0 additions & 5 deletions ore/conf/ore-default-settings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,6 @@ sponge {
"image": "images/sponsors/creeperhost.svg",
"link": "https://billing.creeperhost.net/link.php?id=8"
},
{
"name": "Triplequote",
"image": "images/sponsors/triplequote_black.svg",
"link": "https://triplequote.com/hydra"
},
{
"name": "JetBrains",
"image": "images/sponsors/jetbrains.svg",
Expand Down
1 change: 0 additions & 1 deletion ore/public/images/sponsors/triplequote_black.svg

This file was deleted.

1 change: 0 additions & 1 deletion ore/public/images/sponsors/triplequote_white.svg

This file was deleted.

6 changes: 5 additions & 1 deletion orePlayCommon/app/ore/models/project/io/PluginFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ class PluginFile(val path: Path, val user: Model[User]) {
.continually(jarIn.getNextJarEntry)
.takeWhile(_ != null) // scalafix:ok
.filter(entry => fileNames.contains(entry.getName))
.flatMap(entry => PluginFileData.getData(entry.getName, new BufferedReader(new InputStreamReader(jarIn))))
.flatMap { entry =>
PluginFileData.getData(entry.getName, new BufferedReader(new InputStreamReader(jarIn)) {
override def close(): Unit = {}
})
}
.toVector

// Mainfest file isn't read in the jar stream for whatever reason
Expand Down
144 changes: 40 additions & 104 deletions orePlayCommon/app/ore/models/project/io/PluginFileData.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package ore.models.project.io

import scala.language.higherKinds

import java.io.BufferedReader
import com.google.gson.stream.JsonReader

import scala.collection.mutable.ArrayBuffer
import scala.jdk.CollectionConverters._
import scala.jdk.OptionConverters._
import scala.util.control.NonFatal

import ore.data.project.Dependency
import ore.db.{DbRef, Model, ModelService}
import ore.models.project.{TagColor, Version, VersionTag}

import org.spongepowered.plugin.meta.McModInfo
import org.spongepowered.plugin.metadata.builtin.MetadataParser
import org.spongepowered.plugin.metadata.model.PluginDependency

/**
* The metadata within a [[PluginFile]]
Expand Down Expand Up @@ -155,26 +154,26 @@ object McModInfoHandler extends FileTypeHandler("mcmod.info") {
else {
val metadata = info.head

if (metadata.getId != null)
dataValues += StringDataValue("id", metadata.getId)
if (metadata.id != null)
dataValues += StringDataValue("id", metadata.id)

if (metadata.getVersion != null)
dataValues += StringDataValue("version", metadata.getVersion)
if (metadata.version != null)
dataValues += StringDataValue("version", metadata.version)

if (metadata.getName != null)
dataValues += StringDataValue("name", metadata.getName)
if (metadata.name != null)
dataValues += StringDataValue("name", metadata.name)

if (metadata.getDescription != null)
dataValues += StringDataValue("description", metadata.getDescription)
if (metadata.description != null)
dataValues += StringDataValue("description", metadata.description)

if (metadata.getUrl != null)
dataValues += StringDataValue("url", metadata.getUrl)
if (metadata.url != null)
dataValues += StringDataValue("url", metadata.url)

if (metadata.getAuthors != null)
dataValues += StringListValue("authors", metadata.getAuthors.asScala.toSeq)
if (metadata.authors != null)
dataValues += StringListValue("authors", metadata.authors.asScala.toSeq)

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

Expand Down Expand Up @@ -209,98 +208,35 @@ object ModTomlHandler extends FileTypeHandler("mod.toml") {
Nil
}

object SpongeJsonHandler extends FileTypeHandler("META-INF/plugins.json") {

def readDependencies(in: JsonReader) = {
val deps = new ArrayBuffer[Dependency]
in.beginArray()
while (in.hasNext) {
in.beginObject()
var dep = Dependency(null, None)
while (in.hasNext) {
in.nextName() match {
case "id" => dep = dep.copy(pluginId = in.nextString())
case "version" => dep = dep.copy(version = Option(in.nextString()))
case _ => in.skipValue()
}
}
deps += dep
in.endObject()
}
in.endArray()
deps.toSeq
}

def readAuthors(in: JsonReader) = {
val authors = new ArrayBuffer[String]
in.beginArray()
while (in.hasNext) {
in.beginObject()
while (in.hasNext) {
in.nextName() match {
case "name" => authors += in.nextString()
case _ => in.skipValue()
}
}
in.endObject()
}
in.endArray()
authors.toSeq
}

def readDataValue(dvs: ArrayBuffer[DataValue], in: JsonReader) = {
while (in.hasNext) {
in.nextName() match {
case "id" => dvs += StringDataValue("id", in.nextString());
case "version" => dvs += StringDataValue("version", in.nextString());
case "name" => dvs += StringDataValue("name", in.nextString());
case "description" => dvs += StringDataValue("description", in.nextString());
case "contributors" => dvs += StringListValue("authors", readAuthors(in));
case "dependencies" => dvs += DependencyDataValue("dependencies", readDependencies(in));
// case "links" =>
// case "main-class" =>
// case "loader" =>
case _ => in.skipValue() // ignored
}

}
}

def readDataValues(dvs: ArrayBuffer[DataValue], in: JsonReader): Unit = {
var first = true;
in.beginArray()
while (in.hasNext) {
if (first) {
in.beginObject()
readDataValue(dvs, in)
first = false;
in.endObject()
} else {
in.skipValue() // cannot handle multiple plugins for now
}
}
in.endArray()
}
object SpongeJsonHandler extends FileTypeHandler("META-INF/sponge_plugins.json") {

override def getData(bufferedReader: BufferedReader): Seq[DataValue] = {
val dataValues = new ArrayBuffer[DataValue]
try {
val reader = new JsonReader(bufferedReader)
reader.beginObject()
try {
if (reader.hasNext) {
if (reader.nextName().equals("plugins")) {
readDataValues(dataValues, reader)
}
}
} finally {
reader.endObject()
}
dataValues.toSeq
val metadata = MetadataParser.read(bufferedReader)
val firstPlugin = metadata.metadata.asScala.head
Seq[DataValue](
StringDataValue("id", firstPlugin.id),
StringDataValue("version", firstPlugin.version.toString),
StringListValue("authors", firstPlugin.contributors.asScala.map(_.name).toSeq),
DependencyDataValue("dependencies", readDependencies(firstPlugin.dependencies.asScala))
) ++ Seq(
firstPlugin.name.toScala.map(v => StringDataValue("name", v)),
firstPlugin.description.toScala.map(v => StringDataValue("description", v))
).flatten
} catch {
case NonFatal(e) =>
case NonFatal(e) => {
e.printStackTrace()
Nil
}
}
}

def readDependencies(in: Iterable[PluginDependency]): Seq[Dependency] =
in.map { dep =>
Dependency(
dep.id,
Option.when(dep.version.hasRestrictions || dep.version.getRecommendedVersion != null)(dep.version.toString)
)
}.toSeq

}
2 changes: 1 addition & 1 deletion project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object Settings {
val scalaVer = "2.13.6"

val commonSettings = Seq(
version := "2.0.0-M2.4",
version := "2.0.0-M2.5",
scalaVersion := scalaVer,
scalacOptions ++= Seq(
"-deprecation",
Expand Down
6 changes: 5 additions & 1 deletion project/dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ object Deps {
"ext-wikilink"
).map(flexmarkDep)

val pluginMeta = "org.spongepowered" % "plugin-meta" % "0.4.1"
// Sponge API-8+
val pluginMeta = "org.spongepowered" % "plugin-meta" % "0.8.0"

// mcmod.info
val pluginMetaMcMod = "org.spongepowered.plugin-meta" % "mcmod-info" % "0.8.0"

val javaxMail = "javax.mail" % "mail" % "1.4.7"
val postgres = "org.postgresql" % "postgresql" % "42.2.16"
Expand Down

0 comments on commit 6a20037

Please sign in to comment.