diff --git a/README.md b/README.md index af9bcbe71..74a286c87 100644 --- a/README.md +++ b/README.md @@ -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", - "", - "") - resolvers += Resolver.url("Triplequote Plugins Releases", url("https://repo.triplequote.com/artifactory/sbt-plugins-release/"))(Resolver.ivyStylePatterns) - addSbtPlugin("com.triplequote" % "sbt-hydra" % "") - ``` - - The `` and `` placeholders have to be replaced with your credentials. - - The `` 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 `` is your personal hydra license key: - - ``` - hydraActivateLicense - ``` - -4. Go and start compiling! - -Further instructions can be found at the [official Hydra documentation](https://docs.triplequote.com/). diff --git a/apiV2/app/models/querymodels/apiV2QueryModels.scala b/apiV2/app/models/querymodels/apiV2QueryModels.scala index 9505de1eb..e0be57e02 100644 --- a/apiV2/app/models/querymodels/apiV2QueryModels.scala +++ b/apiV2/app/models/querymodels/apiV2QueryModels.scala @@ -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 { diff --git a/build.sbt b/build.sbt index ecc4496f0..c2b170a82 100755 --- a/build.sbt +++ b/build.sbt @@ -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, diff --git a/ore/conf/ore-default-settings.conf b/ore/conf/ore-default-settings.conf index a1f8a15c7..f4b6450a9 100644 --- a/ore/conf/ore-default-settings.conf +++ b/ore/conf/ore-default-settings.conf @@ -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", diff --git a/ore/public/images/sponsors/triplequote_black.svg b/ore/public/images/sponsors/triplequote_black.svg deleted file mode 100644 index 7b940fcf1..000000000 --- a/ore/public/images/sponsors/triplequote_black.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/ore/public/images/sponsors/triplequote_white.svg b/ore/public/images/sponsors/triplequote_white.svg deleted file mode 100644 index 21e26386a..000000000 --- a/ore/public/images/sponsors/triplequote_white.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/orePlayCommon/app/ore/models/project/io/PluginFile.scala b/orePlayCommon/app/ore/models/project/io/PluginFile.scala index fc458abc3..0401fa2bc 100644 --- a/orePlayCommon/app/ore/models/project/io/PluginFile.scala +++ b/orePlayCommon/app/ore/models/project/io/PluginFile.scala @@ -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 diff --git a/orePlayCommon/app/ore/models/project/io/PluginFileData.scala b/orePlayCommon/app/ore/models/project/io/PluginFileData.scala index b4bdb7324..0f90eb737 100644 --- a/orePlayCommon/app/ore/models/project/io/PluginFileData.scala +++ b/orePlayCommon/app/ore/models/project/io/PluginFileData.scala @@ -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]] @@ -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) } @@ -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 + } diff --git a/project/Settings.scala b/project/Settings.scala index 32cd91f2a..5d464b1f6 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -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", diff --git a/project/dependencies.scala b/project/dependencies.scala index 4fbadf9f5..560e6da18 100644 --- a/project/dependencies.scala +++ b/project/dependencies.scala @@ -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"