Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Additional set of changes, using the config support

  • Loading branch information...
commit 9ea1de03ef081ad250d16391cbdd2152b81df2d7 1 parent 2008255
@skyluc skyluc authored
View
2  src/main/scala/org/scalaide/buildtools/Ecosystem.scala
@@ -27,7 +27,7 @@ object Ecosystem {
/** default location of the feature description fise in a feature project */
val FeatureDescriptor = "feature.xml"
/** default location of the ecosystem configuration */
- val EcosystemConfigFile = "config.properties"
+ val EcosystemConfigFile = "ecosystem.conf"
/** default location of the feature configuration files */
val EcosystemFeatureFolder = "features"
View
52 src/main/scala/org/scalaide/buildtools/EcosystemConfig.scala
@@ -1,52 +0,0 @@
-package org.scalaide.buildtools
-
-import java.io.File
-import scala.io.Source
-import scala.collection.Iterator
-import scala.collection.immutable.HashMap
-import scala.annotation.tailrec
-
-object EcosystemConfig {
- import Ecosystem._
-
- // regex for the config file
- private val ConfigCategory = "category.([^=]*)=(.*)".r
- private val ConfigRepository = "ecosystemBaseRepository.([^=]*)=(.*)".r
-
- def apply(configFile: File): Either[String, EcosystemConfig] = {
- for {
- content <- getContent(configFile).right
- parsedContent <- parseContent(content).right
- } yield new EcosystemConfig(parsedContent._1, parsedContent._2)
- }
-
- private def parseContent(lines: Iterator[String]): Either[String, (Map[String, String], List[EcosystemRepository])] = {
- @tailrec
- def loop(categories: Map[String, String], repositories: List[EcosystemRepository]): Either[String, (Map[String, String], List[EcosystemRepository])] = {
- if (lines.hasNext) {
- lines.next match {
- case ConfigComment =>
- loop(categories, repositories)
- case ConfigRepository(id, location) =>
- loop(categories, repositories :+ EcosystemRepository(id, location))
- case ConfigCategory(id, name) =>
- loop(categories + (id -> name), repositories)
- case l =>
- Left("'%s' is an invalid ecosystem config line".format(l))
- }
- } else {
- Right((categories, repositories))
- }
- }
- // TODO: check if any repository defined
- loop(Map(), Nil)
- }
-
-}
-
-case class EcosystemConfig(categories: Map[String, String], repositories: List[EcosystemRepository])
-
-case class EcosystemRepository(id: String, location: String, baseLocation: String) {
- def getRepository() = Repositories(location)
- def getBaseRepository() = Repositories(baseLocation)
-}
View
52 src/main/scala/org/scalaide/buildtools/EcosystemConfig.scala.old
@@ -0,0 +1,52 @@
+package org.scalaide.buildtools
+
+import java.io.File
+import scala.io.Source
+import scala.collection.Iterator
+import scala.collection.immutable.HashMap
+import scala.annotation.tailrec
+
+//object EcosystemConfig {
+// import Ecosystem._
+//
+// // regex for the config file
+// private val ConfigCategory = "category.([^=]*)=(.*)".r
+// private val ConfigRepository = "ecosystemBaseRepository.([^=]*)=(.*)".r
+//
+// def apply(configFile: File): Either[String, EcosystemConfig] = {
+// for {
+// content <- getContent(configFile).right
+// parsedContent <- parseContent(content).right
+// } yield new EcosystemConfig(parsedContent._1, parsedContent._2)
+// }
+//
+// private def parseContent(lines: Iterator[String]): Either[String, (Map[String, String], List[EcosystemRepository])] = {
+// @tailrec
+// def loop(categories: Map[String, String], repositories: List[EcosystemRepository]): Either[String, (Map[String, String], List[EcosystemRepository])] = {
+// if (lines.hasNext) {
+// lines.next match {
+// case ConfigComment =>
+// loop(categories, repositories)
+// case ConfigRepository(id, location) =>
+// loop(categories, repositories :+ EcosystemRepository(id, location))
+// case ConfigCategory(id, name) =>
+// loop(categories + (id -> name), repositories)
+// case l =>
+// Left("'%s' is an invalid ecosystem config line".format(l))
+// }
+// } else {
+// Right((categories, repositories))
+// }
+// }
+// // TODO: check if any repository defined
+// loop(Map(), Nil)
+// }
+//
+//}
+//
+//case class EcosystemConfig(categories: Map[String, String], repositories: List[EcosystemRepository])
+
+case class EcosystemRepositoryOld(id: String, location: String, baseLocation: String) {
+// def getRepository() = Repositories(location)
+// def getBaseRepository() = Repositories(baseLocation)
+}
View
9 src/main/scala/org/scalaide/buildtools/EcosystemsDescriptor.scala
@@ -31,12 +31,14 @@ import java.io.File
* }
*/
class EcosystemsDescriptor(config: Config) {
- val ecosystems: List[Ecosystem] = {
+ val ecosystems: List[EcosystemDescriptor] = {
val ids = config.getStringList(EcosystemsDescriptor.Keys.idsKey).asScala.toList
for(ecosystemId <- ids) yield {
val site = config.getString(EcosystemsDescriptor.Keys.site(ecosystemId))
val siteUrl = new URL(site)
- Ecosystem(ecosystemId, siteUrl)
+ val baseSite = config.getString(EcosystemsDescriptor.Keys.baseSite(ecosystemId))
+ val baseSiteUrl = new URL(baseSite)
+ EcosystemDescriptor(ecosystemId, siteUrl, baseSiteUrl)
}
}
}
@@ -46,6 +48,7 @@ object EcosystemsDescriptor {
val root = "ecosystems-descriptor"
val idsKey = root + ".ids"
def site(ecosystemId: String): String = root + "." + ecosystemId + ".site"
+ def baseSite(ecosystemId: String): String = root + "." + ecosystemId + ".baseSite"
}
def load(file: File): EcosystemsDescriptor = {
@@ -53,4 +56,4 @@ object EcosystemsDescriptor {
}
}
-final case class Ecosystem(id: String, site: URL)
View
67 src/main/scala/org/scalaide/buildtools/GenerateEcosystemBuilds.scala
@@ -3,15 +3,16 @@ package org.scalaide.buildtools
import java.io.File
import scala.annotation.tailrec
import scala.collection.mutable.HashMap
+import java.net.URL
/**
* !!! This object not thread safe !!! It was used in a single threaded system when implemented.
*/
object Repositories {
- val repos = HashMap[String, Either[String, P2Repository]]()
+ val repos = HashMap[URL, Either[String, P2Repository]]()
- def apply(location: String): Either[String, P2Repository] = {
+ def apply(location: URL): Either[String, P2Repository] = {
repos.get(location) match {
case Some(repo) =>
repo
@@ -43,18 +44,26 @@ class GenerateEcosystemBuilds(rootFolder: String) {
import Ecosystem._
def apply(): Either[String, AnyRef] = {
+
+ val ecosystems= EcosystemsDescriptor.load(new File(rootFolder, EcosystemConfigFile)).ecosystems
+ val requestedFeatures= PluginDescriptor.loadAll(new File(rootFolder, "features")).flatMap(_ match {
+ case Right(conf) =>
+ Some(conf)
+ case Left(_) =>
+ None
+ })
+
for {
- config <- EcosystemConfig(new File(rootFolder, EcosystemConfigFile)).right
- requestedFeatures <- RequestedFeature.parseConfigFiles(new File(rootFolder, EcosystemFeatureFolder)).right
- availableFeatures <- findFeatures(requestedFeatures).right
- ecosystemToScalaIDEToAvailableFeatures <- getAvailableScalaIDEs(config, requestedFeatures, availableFeatures).right
- } yield MavenProject.generateEcosystemsProjects(ecosystemToScalaIDEToAvailableFeatures, new File(rootFolder))
-
+ availableFeatures <- findFeatures(requestedFeatures.toList).right
+ ecosystemToScalaIDEToAvailableFeatures <- getAvailableScalaIDEs(ecosystems, requestedFeatures.toList, availableFeatures).right
+ } yield MavenProject2.generateEcosystemsProjects(ecosystemToScalaIDEToAvailableFeatures, new File(rootFolder, "target/builds"))
+
+
}
- private def getAvailableScalaIDEs(config: EcosystemConfig, requestedFeatures: List[RequestedFeature], availableFeatures: List[FeatureDefinition]): Either[String, Map[EcosystemRepository, Map[ScalaIDEDefinition, List[FeatureDefinition]]]] = {
+ private def getAvailableScalaIDEs(ecosystems: List[EcosystemDescriptor], requestedFeatures: List[PluginDescriptor], availableFeatures: List[FeatureDefinition]): Either[String, Map[EcosystemDescriptor, Map[ScalaIDEDefinition, List[FeatureDefinition]]]] = {
@tailrec
- def loop(repositories: List[EcosystemRepository], definitions: Map[EcosystemRepository, Map[ScalaIDEDefinition, List[FeatureDefinition]]]): Either[String, Map[EcosystemRepository, Map[ScalaIDEDefinition, List[FeatureDefinition]]]] = {
+ def loop(repositories: List[EcosystemDescriptor], definitions: Map[EcosystemDescriptor, Map[ScalaIDEDefinition, List[FeatureDefinition]]]): Either[String, Map[EcosystemDescriptor, Map[ScalaIDEDefinition, List[FeatureDefinition]]]] = {
repositories match {
case Nil =>
Right(definitions)
@@ -67,30 +76,30 @@ class GenerateEcosystemBuilds(rootFolder: String) {
}
}
}
- loop(config.repositories, Map())
+ loop(ecosystems, Map())
}
- private def findScalaIDEsAndResolvedAvailableFeatures(repositoryDefinition: EcosystemRepository, requestedFeatures: List[RequestedFeature], availableFeatures: List[FeatureDefinition]): Either[String, Map[ScalaIDEDefinition, List[FeatureDefinition]]] = {
+ private def findScalaIDEsAndResolvedAvailableFeatures(ecosystem: EcosystemDescriptor, requestedFeatures: List[PluginDescriptor], availableFeatures: List[FeatureDefinition]): Either[String, Map[ScalaIDEDefinition, List[FeatureDefinition]]] = {
for {
- repository <- repositoryDefinition.getRepository.right
- } yield findScalaIDEsAndResolvedAvailableFeatures(repository, requestedFeatures, availableFeatures)
+ repository <- Repositories(ecosystem.site).right
+ baseRepository <- Repositories(ecosystem.baseSite).right
+ } yield findScalaIDEsAndResolvedAvailableFeatures(repository, baseRepository, requestedFeatures, availableFeatures)
}
- private def findScalaIDEsAndResolvedAvailableFeatures(repository: P2Repository, requestedFeatures: List[RequestedFeature], availableFeatures: List[FeatureDefinition]): Map[ScalaIDEDefinition, List[FeatureDefinition]] = {
+ private def findScalaIDEsAndResolvedAvailableFeatures(repository: P2Repository, baseRepository: P2Repository, requestedFeatures: List[PluginDescriptor], availableFeatures: List[FeatureDefinition]): Map[ScalaIDEDefinition, List[FeatureDefinition]] = {
val allAvailableFeatures = mergeFeatureList(availableFeatures, findExistingFeatures(requestedFeatures, repository))
- repository.findIU(ScalaIDEFeatureIdOsgi).map(ScalaIDEDefinition(_, repository))
- repository.findIU(ScalaIDEFeatureIdOsgi).foldLeft(Map[ScalaIDEDefinition, List[FeatureDefinition]]())((m, ui) =>
+ baseRepository.findIU(ScalaIDEFeatureIdOsgi).foldLeft(Map[ScalaIDEDefinition, List[FeatureDefinition]]())((m, ui) =>
// TODO: might be a nice place to check versions
- m + (ScalaIDEDefinition(ui, repository) -> allAvailableFeatures.filter(f => ScalaIDEDefinition.matches(ui.version, f.sdtFeatureRange.range))))
+ m + (ScalaIDEDefinition(ui, baseRepository) -> allAvailableFeatures.filter(f => ScalaIDEDefinition.matches(ui.version, f.sdtFeatureRange.range))))
}
- private def findFeatures(requestedFeatures: List[RequestedFeature]): Either[String, List[FeatureDefinition]] = {
+ private def findFeatures(requestedFeatures: List[PluginDescriptor]): Either[String, List[FeatureDefinition]] = {
Right(requestedFeatures.flatMap(findFeatures(_)))
}
- private def findFeatures(requestedFeature: RequestedFeature): Seq[FeatureDefinition] = {
- requestedFeature.repositories.flatMap { location =>
+ private def findFeatures(requestedFeature: PluginDescriptor): List[FeatureDefinition] = {
+ requestedFeature.updateSites.flatMap { location =>
Repositories(location) match {
case Right(p2repo) =>
findFeatures(requestedFeature, p2repo)
@@ -100,8 +109,8 @@ class GenerateEcosystemBuilds(rootFolder: String) {
}
}
- private def findFeatures(feature: RequestedFeature, repository: P2Repository): Seq[FeatureDefinition] = {
- repository.findIU(feature.id + FeatureSuffix).map(FeatureDefinition(feature, _, repository))
+ private def findFeatures(feature: PluginDescriptor, repository: P2Repository): List[FeatureDefinition] = {
+ repository.findIU(feature.featureId + FeatureSuffix).map(FeatureDefinition(feature, _, repository))
}
private def mergeFeatureList(base: List[FeatureDefinition], toMerge: List[FeatureDefinition]): List[FeatureDefinition] = {
@@ -122,7 +131,7 @@ class GenerateEcosystemBuilds(rootFolder: String) {
res
}
- private def findExistingFeatures(requestedFeatures: List[RequestedFeature], repository: P2Repository): List[FeatureDefinition] = {
+ private def findExistingFeatures(requestedFeatures: List[PluginDescriptor], repository: P2Repository): List[FeatureDefinition] = {
requestedFeatures.flatMap(findFeatures(_, repository))
}
@@ -154,16 +163,16 @@ object ScalaIDEDefinition {
new ScalaIDEDefinition(feature.version, sdtCore, scalaLibrary, scalaCompiler, repository)
}
- def allDependencies(iu: InstallableUnit, repository: P2Repository): Seq[DependencyUnit] = {
+ def allDependencies(iu: InstallableUnit, repository: P2Repository): List[DependencyUnit] = {
iu.dependencies ++ iu.dependencies.flatMap(allDependencies(_, repository))
}
- def allDependencies(du: DependencyUnit, repository: P2Repository): Seq[DependencyUnit] = {
+ def allDependencies(du: DependencyUnit, repository: P2Repository): List[DependencyUnit] = {
repository.findIU(du.id).filter(iu => matches(iu.version, du.range)) match {
case Nil =>
// not part of this repository, fine
Nil
- case Seq(iu) =>
+ case List(iu) =>
// this is the one we are looking for
val dep = allDependencies(iu, repository)
dep
@@ -186,7 +195,7 @@ object ScalaIDEDefinition {
}
case class FeatureDefinition(
- details: RequestedFeature,
+ details: PluginDescriptor,
version: String,
sdtFeatureRange: DependencyUnit,
sdtCoreRange: DependencyUnit,
@@ -197,7 +206,7 @@ case class FeatureDefinition(
object FeatureDefinition {
import Ecosystem._
- def apply(details: RequestedFeature, iu: InstallableUnit, repository: P2Repository): FeatureDefinition = {
+ def apply(details: PluginDescriptor, iu: InstallableUnit, repository: P2Repository): FeatureDefinition = {
val dependencies = ScalaIDEDefinition.allDependencies(iu, repository)
val sdtCore = dependencies.find(_.id == ScalaIDEId)
View
4 src/main/scala/org/scalaide/buildtools/MavenProject.scala
@@ -6,7 +6,7 @@ import scala.xml.XML
object MavenProject {
import Ecosystem._
-
+/*
def generateEcosystemsProjects(ecosystemToScalaIDEToAvailableFeatures: Map[EcosystemRepository, Map[ScalaIDEDefinition, List[FeatureDefinition]]], location: File): String = {
val baseFolder = new File(location, "target/build")
@@ -185,5 +185,5 @@ object MavenProject {
<url>{ repository.location }</url>
</repository>
}
-
+*/
}
View
239 src/main/scala/org/scalaide/buildtools/MavenProject2.scala
@@ -0,0 +1,239 @@
+package org.scalaide.buildtools
+
+import java.io.File
+import java.net.URL
+import scala.xml.Elem
+import scala.xml.XML
+
+object MavenProject2 {
+
+ private def saveXml(file: File, xml: Elem) {
+ XML.save(file.getAbsolutePath(), xml, "UTF-8", true)
+ }
+
+ def generateEcosystemsProjects(ecosystemToScalaIDEToAvailableFeatures: Map[EcosystemDescriptor, Map[ScalaIDEDefinition, Seq[FeatureDefinition]]], baseFolder: File): String = {
+
+ if (baseFolder.exists()) {
+ FileUtils.deleteFull(baseFolder)
+ }
+ baseFolder.mkdirs()
+
+ val ecosystemFolders = ecosystemToScalaIDEToAvailableFeatures.map(e => generateEcosystemProject(e._1, e._2, baseFolder)).toSeq
+
+ saveXml(new File(baseFolder, "pom.xml"), createTopPomXml(ecosystemFolders))
+
+ "OK"
+ }
+
+ def generateEcosystemProject(ecosystem: EcosystemDescriptor, scalaIDEToAvailableFeatures: Map[ScalaIDEDefinition, Seq[FeatureDefinition]], baseFolder: File): File = {
+ val ecosystemFolder = new File(baseFolder, ecosystem.id)
+ ecosystemFolder.mkdir()
+
+ val artifactId = "ecosystem.%s".format(ecosystem.id)
+
+ val featureFolders: Seq[File] = scalaIDEToAvailableFeatures.flatMap(s => generateScalaIDEProjects(s._1, s._2, artifactId, Iterator.from(1), ecosystemFolder)).toSeq
+
+ saveXml(new File(ecosystemFolder, "pom.xml"), createEcosystemPomXml(artifactId, ecosystem.baseSite, ecosystemFolder, featureFolders))
+
+ ecosystemFolder
+ }
+
+ def generateScalaIDEProjects(scalaIDE: ScalaIDEDefinition, features: Seq[FeatureDefinition], parentId: String, idCounter: Iterator[Int], baseFolder: File): Seq[File] = {
+ val scalaIDEFolder = new File(baseFolder, scalaIDE.sdtFeatureVersion)
+ scalaIDEFolder.mkdir()
+
+ features.map(f => generateFeatureProject(f, parentId, scalaIDE.repository, idCounter, scalaIDEFolder))
+ }
+
+ def generateFeatureProject(feature: FeatureDefinition, parentId: String, scalaIDERepository: P2Repository, idCounter: Iterator[Int], baseFolder: File): File = {
+ val featureFolder = new File(baseFolder, feature.details.featureId)
+ featureFolder.mkdir()
+
+ saveXml(new File(featureFolder, "pom.xml"), createFeaturePomXml(feature.repository, scalaIDERepository, parentId, idCounter.next))
+ saveXml(new File(featureFolder, "site.xml"), createSiteXml(feature))
+
+ featureFolder
+ }
+
+ def createTopPomXml(ecosystemFolders: Seq[File]) = {
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
+ <groupId>org.scalaide</groupId>
+ <artifactId>ecosystem.build</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <description>Build a repository containing multiple versions</description>
+ <packaging>pom</packaging>
+ <properties>
+ <encoding>UTF-8</encoding>
+ <tycho.version>0.15.0</tycho.version>
+ </properties>
+ <modules>
+ {
+ ecosystemFolders.map { f =>
+ <module>{ f.getName }</module>
+ }
+ }
+ </modules>
+ </project>
+ }
+
+ def createEcosystemPomXml(id: String, baseSite: URL, ecosystemFolder: File, featureFolders: Seq[File]) = {
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
+ <parent>
+ <groupId>org.scalaide</groupId>
+ <artifactId>ecosystem.build</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>{ id }</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <description>Build a repository containing multiple versions</description>
+ <packaging>pom</packaging>
+ <properties>
+ <encoding>UTF-8</encoding>
+ <tycho.version>0.15.0</tycho.version>
+ </properties>
+ <profiles>
+ <profile>
+ <id>package</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho.extras</groupId>
+ <artifactId>tycho-p2-extras-plugin</artifactId>
+ <version>${{tycho.version}}</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>mirror</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <source>
+ <repository>
+ <url>{ baseSite }</url>
+ <layout>p2</layout>
+ </repository>
+ {
+ featureFolders.map { f =>
+ <repository>
+ <url>{ new File(f, "target/site").toURI() }</url>
+ <layout>p2</layout>
+ </repository>
+
+ }
+ }
+ </source>
+ <destination>${{project.build.directory}}/site</destination>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>build</id>
+ <modules>
+ {
+ featureFolders.map { f =>
+ <module>{ "%s/%s".format(f.getParentFile.getName, f.getName) }</module>
+ }
+ }
+ </modules>
+ </profile>
+ </profiles>
+ </project>
+ }
+
+ def createFeaturePomXml(featureRepository: P2Repository, scalaIDERepository: P2Repository, parentId: String, id: Int) = {
+ // TODO: support for non-indigo build
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
+ <parent>
+ <groupId>org.scalaide</groupId>
+ <artifactId>{ parentId }</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <artifactId>org.scala-ide.ecosystem.generated{ id }</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <description>Build project for the scalatest support in Scala IDE</description>
+ <packaging>eclipse-update-site</packaging>
+ <properties>
+ <encoding>UTF-8</encoding>
+ <tycho.version>0.15.0</tycho.version>
+ <!-- p2 repositories location -->
+ <repo.eclipse.indigo>http://download.eclipse.org/releases/indigo/</repo.eclipse.indigo>
+ <!-- dependencies repos -->
+ <eclipse.codename>indigo</eclipse.codename>
+ </properties>
+ <repositories>
+ <repository>
+ <id>eclipse.indigo</id>
+ <name>Eclipse p2 repository</name>
+ <layout>p2</layout>
+ <url>http://download.eclipse.org/releases/indigo/</url>
+ </repository>
+ <repository>
+ <id>scalaide.repo</id>
+ <layout>p2</layout>
+ <url>{ scalaIDERepository.location }</url>
+ </repository>
+ <repository>
+ <id>feature.repo</id>
+ <layout>p2</layout>
+ <url>{ featureRepository.location }</url>
+ </repository>
+ </repositories>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${{tycho.version}}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-packaging-plugin</artifactId>
+ <version>${{tycho.version}}</version>
+ <configuration>
+ <archiveSite>true</archiveSite>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </project>
+ }
+
+ private def createSiteXml(feature: FeatureDefinition) = {
+ <site>
+ { featureXml(feature) }
+ <category-def name="stable" label="Scala IDE plugins"/>
+ <category-def name="incubation" label="Scala IDE plugins (incubation)"/>
+ <category-def name="source" label="Sources"/>
+ </site>
+ }
+
+ private def featureXml(feature: FeatureDefinition): List[Elem] =
+ // TODO: fix category
+ // TODO: fix sourceFeatureId, should be option
+ List(featureXml(feature.details.featureId, feature.version, "incubation")) :+ featureXml(feature.details.sourceFeatureId, feature.version, "source")
+
+ private def featureXml(id: String, version: String, category: String): Elem = {
+ <feature url={ "features/" + id + "_0.0.0.jar" } id={ id } version={ version }>
+ <category name={ category }/>
+ </feature>
+ }
+
+}
View
23 src/main/scala/org/scalaide/buildtools/P2Repository.scala
@@ -9,7 +9,7 @@ import java.io.IOException
import java.util.zip.ZipException
import scala.xml.Elem
import org.xml.sax.SAXException
-import java.net.URL
+import java.net.{URL => jURL}
import scala.xml.Node
case class DependencyUnit(id: String, range: String)
@@ -26,7 +26,7 @@ object DependencyUnit {
}
-case class InstallableUnit(id: String, version: String, dependencies: Seq[DependencyUnit])
+case class InstallableUnit(id: String, version: String, dependencies: List[DependencyUnit])
object InstallableUnit {
def apply(unit: Node): Option[InstallableUnit] = {
@@ -36,8 +36,8 @@ object InstallableUnit {
None
}
- private def getDependencies(unit: Node): Seq[DependencyUnit] = {
- unit \ "requires" \ "required" flatMap (DependencyUnit(_))
+ private def getDependencies(unit: Node): List[DependencyUnit] = {
+ (unit \ "requires" \ "required" flatMap {d: Node => DependencyUnit(d)}).toList
}
private def isBundle(unit: Node) = unit \ "artifacts" \ "artifact" \ "@classifier" exists (a => a.text == "osgi.bundle")
@@ -47,10 +47,10 @@ object InstallableUnit {
case class P2Repository(uis: Map[String, Seq[InstallableUnit]], location: String) {
- def findIU(pattern: String): Seq[InstallableUnit] = {
+ def findIU(pattern: String): List[InstallableUnit] = {
uis.flatMap { entry =>
if (entry._1.matches(pattern)) entry._2 else Nil
- }.toSeq
+ }.toList
}
override def toString = "P2Repository(%s)".format(location)
@@ -84,12 +84,15 @@ object P2Repository {
* to the current process.
*/
def fromUrl(repoUrl: String): Either[String, P2Repository] = {
- val url = new URL(repoUrl)
- url.getProtocol() match {
+ fromUrl(new jURL(repoUrl))
+ }
+
+ def fromUrl(repoUrl: jURL): Either[String, P2Repository] = {
+ repoUrl.getProtocol() match {
case "file" =>
- fromLocalFolder(url.getFile())
+ fromLocalFolder(repoUrl.getFile())
case _ =>
- fromHttpUrl(repoUrl)
+ fromHttpUrl(repoUrl.toExternalForm())
}
}
View
6 src/main/scala/org/scalaide/buildtools/PluginDescriptor.scala
@@ -77,6 +77,10 @@ final class PluginDescriptor(name: String, config: Config) {
case None => throw new FailedToRetrieveKeyOrValue(name, path, new NoSuchElementException(path))
case Some(string) => string
}
+
+ override def toString() = {
+ "PluginDescriptor(%s)".format(name)
+ }
}
object PluginDescriptor {
@@ -105,7 +109,7 @@ object PluginDescriptor {
private case object Stable extends Category
/** Load in memory all plugin descriptors files in the passed `folder`.*/
- def loadAll(folder: File): Array[Either[PluginDescriptorException, PluginDescriptor]] = {
+ def loadAll(folder: File): Seq[Either[PluginDescriptorException, PluginDescriptor]] = {
require(folder.isDirectory, folder.getAbsolutePath + " is not a folder")
val files = folder.listFiles()
View
89 src/main/scala/org/scalaide/buildtools/RequestedFeature.scala
@@ -1,89 +0,0 @@
-package org.scalaide.buildtools
-
-import java.io.File
-import scala.annotation.tailrec
-
-object RequestedFeature {
- import Ecosystem._
-
- // regex for the feature config file
- private val ConfigCategory = "category=(.*)".r
- private val ConfigSource = "source=(.*)".r
- private val ConfigRepository = "repository=(.*)".r
-
- def parseConfigFiles(baseFolder: File): Either[String, List[RequestedFeature]] = {
- if (baseFolder.exists && baseFolder.isDirectory()) {
- parseConfigFiles(baseFolder.listFiles())
- } else {
- Left("%s doesn't exist or is not a directory".format(baseFolder))
- }
- }
-
- private def parseConfigFiles(files: Array[File]): Either[String, List[RequestedFeature]] = {
- @tailrec
- def loop(files: List[File], features: List[RequestedFeature]): Either[String, List[RequestedFeature]] = {
- files match {
- case Nil =>
- Right(features)
- case head :: tail =>
- parseConfigFile(head) match {
- case Right(feature) =>
- loop(tail, features :+ feature)
- case Left(error) =>
- Left(error)
- }
- }
- }
- loop(files.toList, List())
- }
-
- private def parseConfigFile(file: File): Either[String, RequestedFeature] = {
- val id = file.getName()
- for {
- content <- getContent(file).right
- parsedContent <- parseContent(content, id).right
- } yield new RequestedFeature(id, parsedContent._1, parsedContent._2, parsedContent._3)
- }
-
- private def parseContent(lines: Iterator[String], id: String): Either[String, (String, Option[String], List[String])] = {
- def loop(category: Option[String], source: Option[String], repositories: List[String]): Either[String, (Option[String], Option[String], List[String])] = {
- if (lines.hasNext) {
- lines.next match {
- case ConfigComment =>
- loop(category, source, repositories)
- case ConfigCategory(c) =>
- if (category.isDefined) {
- Left("Category is defined twice for %s".format(id))
- } else {
- loop(Some(c), source, repositories)
- }
- case ConfigRepository(location) =>
- loop(category, source, repositories :+ location)
- case ConfigSource(sourceId) =>
- if (source.isDefined) {
- Left("Source is defined twice for %s".format(id))
- } else {
- loop(category, Some(sourceId), repositories)
- }
- case l =>
- Left("'%s' is an invalid config line for %s".format(l, id))
- }
- } else {
- Right((category, source, repositories))
- }
- }
- loop(None, None, List()) match {
- case Left(error) =>
- Left(error)
- case Right((None, _, _)) =>
- Left("No category defined for %s".format(id))
- case Right((_, _, Nil)) =>
- Left("No repository defined for %s".format(id))
- case Right((Some(category), source, repositories)) =>
- Right((category, source, repositories))
- }
- }
-
-}
-
-case class RequestedFeature(id: String, category: String, source: Option[String], repositories: List[String])
View
89 src/main/scala/org/scalaide/buildtools/RequestedFeature.scala.old
@@ -0,0 +1,89 @@
+package org.scalaide.buildtools
+
+import java.io.File
+import scala.annotation.tailrec
+
+object RequestedFeatureOld {
+// import Ecosystem._
+
+// // regex for the feature config file
+// private val ConfigCategory = "category=(.*)".r
+// private val ConfigSource = "source=(.*)".r
+// private val ConfigRepository = "repository=(.*)".r
+//
+// def parseConfigFiles(baseFolder: File): Either[String, List[RequestedFeatureOld]] = {
+// if (baseFolder.exists && baseFolder.isDirectory()) {
+// parseConfigFiles(baseFolder.listFiles())
+// } else {
+// Left("%s doesn't exist or is not a directory".format(baseFolder))
+// }
+// }
+//
+// private def parseConfigFiles(files: Array[File]): Either[String, List[RequestedFeatureOld]] = {
+//// @tailrec
+//// def loop(files: List[File], features: List[RequestedFeatureOld]): Either[String, List[RequestedFeatureOld]] = {
+//// files match {
+//// case Nil =>
+//// Right(features)
+//// case head :: tail =>
+//// parseConfigFile(head) match {
+//// case Right(feature) =>
+//// loop(tail, features :+ feature)
+//// case Left(error) =>
+//// Left(error)
+//// }
+//// }
+//// }
+//// loop(files.toList, List())
+// }
+
+// private def parseConfigFile(file: File): Either[String, RequestedFeatureOld] = {
+// val id = file.getName()
+//// for {
+//// content <- getContent(file).right
+//// parsedContent <- parseContent(content, id).right
+//// } yield new RequestedFeatureOld(id, parsedContent._1, parsedContent._2, parsedContent._3)
+// }
+//
+// private def parseContent(lines: Iterator[String], id: String): Either[String, (String, Option[String], List[String])] = {
+// def loop(category: Option[String], source: Option[String], repositories: List[String]): Either[String, (Option[String], Option[String], List[String])] = {
+// if (lines.hasNext) {
+// lines.next match {
+// case ConfigComment =>
+// loop(category, source, repositories)
+// case ConfigCategory(c) =>
+// if (category.isDefined) {
+// Left("Category is defined twice for %s".format(id))
+// } else {
+// loop(Some(c), source, repositories)
+// }
+// case ConfigRepository(location) =>
+// loop(category, source, repositories :+ location)
+// case ConfigSource(sourceId) =>
+// if (source.isDefined) {
+// Left("Source is defined twice for %s".format(id))
+// } else {
+// loop(category, Some(sourceId), repositories)
+// }
+// case l =>
+// Left("'%s' is an invalid config line for %s".format(l, id))
+// }
+// } else {
+// Right((category, source, repositories))
+// }
+// }
+// loop(None, None, List()) match {
+// case Left(error) =>
+// Left(error)
+// case Right((None, _, _)) =>
+// Left("No category defined for %s".format(id))
+// case Right((_, _, Nil)) =>
+// Left("No repository defined for %s".format(id))
+// case Right((Some(category), source, repositories)) =>
+// Right((category, source, repositories))
+// }
+// }
+
+}
+
+case class RequestedFeatureOld(id: String, category: String, source: Option[String], repositories: List[String])
View
8 src/test/scala/org/scalaide/buildtools/EcosystemsDescriptorTests.scala
@@ -13,10 +13,10 @@ class EcosystemsDescriptorTests {
@Test
def ecosystemsDescriptorIsCorrectlyLoaded() {
- val expected = List(Ecosystem("stable-scala29", new URL("http://download.scala-ide.org/ecosystem/scala29/stable/site")),
- Ecosystem("stable-scala210", new URL("http://download.scala-ide.org/ecosystem/scala210/stable/site")),
- Ecosystem("dev-scala29", new URL("http://download.scala-ide.org/ecosystem/scala29/dev/site")),
- Ecosystem("dev-scala210", new URL("http://download.scala-ide.org/ecosystem/scala210/dev/site")))
+ val expected = List(EcosystemDescriptor("stable-scala29", new URL("http://download.scala-ide.org/ecosystem/scala29/stable/site"), new URL("http://download.scala-ide.org/ecosystem/scala29/stable/base/site")),
+ EcosystemDescriptor("stable-scala210", new URL("http://download.scala-ide.org/ecosystem/scala210/stable/site"), new URL("http://download.scala-ide.org/ecosystem/scala210/stable/base/site")),
+ EcosystemDescriptor("dev-scala29", new URL("http://download.scala-ide.org/ecosystem/scala29/dev/site"), new URL("http://download.scala-ide.org/ecosystem/scala29/dev/base/site")),
+ EcosystemDescriptor("dev-scala210", new URL("http://download.scala-ide.org/ecosystem/scala210/dev/site"), new URL("http://download.scala-ide.org/ecosystem/scala210/dev/base/site")))
val resource = EcosystemsDescriptor.getClass().getResource("ecosystems.conf")
val file = new java.io.File(resource.toURI())
View
4 src/test/scala/org/scalaide/buildtools/ecosystems.conf
@@ -3,14 +3,18 @@ ecosystems-descriptor {
stable-scala29 {
site = "http://download.scala-ide.org/ecosystem/scala29/stable/site"
+ baseSite = "http://download.scala-ide.org/ecosystem/scala29/stable/base/site"
}
stable-scala210 {
site = "http://download.scala-ide.org/ecosystem/scala210/stable/site"
+ baseSite = "http://download.scala-ide.org/ecosystem/scala210/stable/base/site"
}
dev-scala29 {
site = "http://download.scala-ide.org/ecosystem/scala29/dev/site"
+ baseSite = "http://download.scala-ide.org/ecosystem/scala29/dev/base/site"
}
dev-scala210 {
site = "http://download.scala-ide.org/ecosystem/scala210/dev/site"
+ baseSite = "http://download.scala-ide.org/ecosystem/scala210/dev/base/site"
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.