Permalink
Browse files

Added support to create a site zip file

The latest version for each current site, with the associated
add-ons, is put in a different update site which can be zipped.
  • Loading branch information...
1 parent 0029433 commit 01b84c2d9c54a3fc1825d2cec220c06975788899 @skyluc skyluc committed Nov 9, 2012
@@ -47,4 +47,6 @@ case class EcosystemBuild(
val regenerateEcosystem: Boolean = !baseScalaIDEVersions.forall(_.associatedAvailableAddOns.isEmpty)
val regenerateNextEcosystem: Boolean = !nextScalaIDEVersions.forall(_.associatedAvailableAddOns.isEmpty)
+
+ val zippedVersion: Option[ScalaIDEVersion] = baseScalaIDEVersions.sortBy(_.version).headOption
}
@@ -3,78 +3,104 @@ package org.scalaide.buildtools
import java.io.File
object EcosystemBuildsMavenProjects {
-
+
private val artifactIdSuffix = Iterator.from(1)
def generate(builds: EcosystemBuilds, targetFolder: File) {
- val buildFolder= new File(targetFolder, "builds")
-
+ val buildFolder = new File(targetFolder, "builds")
+
if (buildFolder.exists) {
FileUtils.deleteFull(buildFolder)
}
buildFolder.mkdirs()
-
+
val ecosystemFolders = builds.ecosystems.flatMap(generateEcosystemProjects(_, buildFolder))
-
+
if (ecosystemFolders.isEmpty) {
println("Nothing to do")
} else {
FileUtils.saveXml(new File(buildFolder, "pom.xml"), createTopPomXml(ecosystemFolders))
}
-
+
}
-
- def generateEcosystemProjects(ecosystemBuild: EcosystemBuild, buildFolder: File): Seq[File]= {
- val ecosystemFolder= new File(buildFolder, ecosystemBuild.id)
-
+
+ def generateEcosystemProjects(ecosystemBuild: EcosystemBuild, buildFolder: File): Seq[File] = {
+ val ecosystemFolder = new File(buildFolder, ecosystemBuild.id)
+
val siteFolder = if (ecosystemBuild.regenerateEcosystem) {
- Some(generateEcosystemProject(ecosystemBuild.baseScalaIDEVersions, "%s-base".format(ecosystemBuild.id), ecosystemBuild.baseRepo, buildFolder))
+ generateEcosystemProject(ecosystemBuild.baseScalaIDEVersions, "%s-base".format(ecosystemBuild.id), ecosystemBuild.baseRepo, buildFolder, ecosystemBuild.zippedVersion)
} else {
- None
+ Nil
}
-
+
val nextFolder = if (ecosystemBuild.regenerateNextEcosystem) {
- Some(generateEcosystemProject(ecosystemBuild.nextScalaIDEVersions, "%s-next".format(ecosystemBuild.id), ecosystemBuild.nextRepo, buildFolder))
+ generateEcosystemProject(ecosystemBuild.nextScalaIDEVersions, "%s-next".format(ecosystemBuild.id), ecosystemBuild.nextRepo, buildFolder, None)
} else {
- None
+ Nil
}
-
+
Seq(siteFolder, nextFolder).flatten
}
-
- def generateEcosystemProject(scalaIDEVersions: Seq[org.scalaide.buildtools.ScalaIDEVersion], tag: String, baseRepository: P2Repository, buildFolder: File): File = {
- val siteFolder= new File(buildFolder, tag)
- siteFolder.mkdirs()
-
- val artifactId = "ecosystem.%s".format(tag)
-
- val featureFolders = scalaIDEVersions.flatMap(generateScalaIDEProjects(_, artifactId, siteFolder))
-
- FileUtils.saveXml(new File(siteFolder, "pom.xml"), createEcosystemPomXml(artifactId, baseRepository, featureFolders))
-
- siteFolder
+
+ def generateEcosystemProject(scalaIDEVersions: Seq[org.scalaide.buildtools.ScalaIDEVersion], tag: String, baseRepository: P2Repository, buildFolder: File, zippedVersion: Option[ScalaIDEVersion]): List[File] = {
+ val siteFolder = new File(buildFolder, tag)
+ siteFolder.mkdirs()
+
+ val artifactId = "ecosystem.%s".format(tag)
+
+ val featureFolders = scalaIDEVersions.map(s => s -> generateScalaIDEProjects(s, artifactId, siteFolder))
+
+ FileUtils.saveXml(new File(siteFolder, "pom.xml"), createEcosystemPomXml(artifactId, baseRepository, featureFolders.flatMap(_._2), siteFolder))
+
+ zippedVersion match {
+ case Some(latestScalaIDEVersion) =>
+ val zipTag = "%s-zip".format(tag)
+
+ val zipFolder = new File(buildFolder, zipTag)
+ zipFolder.mkdirs()
+
+ val featureFoldersLatestVersion = featureFolders.find(_._1 == latestScalaIDEVersion).get._2
+ val scalaIDEFolder = generateScalaIDECloneProject(latestScalaIDEVersion, zipTag, zipFolder)
+
+ FileUtils.saveXml(new File(zipFolder, "pom.xml"), createZipPomXml(zipTag, latestScalaIDEVersion, scalaIDEFolder, featureFoldersLatestVersion, zipFolder))
+
+ List(siteFolder, zipFolder)
+ case None =>
+
+ List(siteFolder)
+ }
}
-
+
def generateScalaIDEProjects(scalaIDEVersion: ScalaIDEVersion, parentId: String, siteFolder: File): Seq[File] = {
- val scalaIDEFolder= new File(siteFolder, scalaIDEVersion.version.toString)
+ val scalaIDEFolder = new File(siteFolder, scalaIDEVersion.version.toString)
scalaIDEFolder.mkdir()
-
+
(scalaIDEVersion.associatedExistingAddOns ++ scalaIDEVersion.associatedAvailableAddOns).map {
case (_, addOn) =>
generateAddOnProject(addOn, scalaIDEVersion, parentId, scalaIDEFolder)
}.toSeq
}
-
+
+ def generateScalaIDECloneProject(scalaIDEVersion: ScalaIDEVersion, parentId: String, zipFolder: File): File = {
+ val scalaIDEFolder = new File(zipFolder, "scalaIDE")
+ scalaIDEFolder.mkdir()
+
+ FileUtils.saveXml(new File(scalaIDEFolder, "pom.xml"), createScalaIDEPomXml(scalaIDEVersion, parentId))
+ FileUtils.saveXml(new File(scalaIDEFolder, "site.xml"), createScalaIDESiteXml(scalaIDEVersion))
+
+ scalaIDEFolder
+ }
+
def generateAddOnProject(addOn: AddOn, scalaIDEVersion: ScalaIDEVersion, parentId: String, scalaIDEFolder: File): File = {
- val addOnFolder= new File(scalaIDEFolder, addOn.id)
+ val addOnFolder = new File(scalaIDEFolder, addOn.id)
addOnFolder.mkdir()
-
+
FileUtils.saveXml(new File(addOnFolder, "pom.xml"), createAddOnPomXml(addOn, scalaIDEVersion, parentId))
FileUtils.saveXml(new File(addOnFolder, "site.xml"), createAddOnSiteXml(addOn))
-
+
addOnFolder
}
-
+
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>
@@ -100,9 +126,7 @@ object EcosystemBuildsMavenProjects {
</project>
}
-
-
- def createEcosystemPomXml(artifactId: String, baseRepository: P2Repository, featureFolders: Seq[File]) = {
+ def createEcosystemPomXml(artifactId: String, baseRepository: P2Repository, featureFolders: Seq[File], buildFolder: 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>
@@ -165,16 +189,152 @@ object EcosystemBuildsMavenProjects {
<modules>
{
featureFolders.map { f =>
- <module>{ "%s/%s".format(f.getParentFile.getName, f.getName) }</module>
+ <module>{ FileUtils.relativePath(buildFolder, f) }</module>
}
}
</modules>
</profile>
</profiles>
</project>
}
-
-
+
+ def createZipPomXml(artifactId: String, latestScalaIDEVersion: ScalaIDEVersion, scalaIDEFolder: File, featureFolders: Seq[File], buildFolder: 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>{ artifactId }</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>{ new File(scalaIDEFolder, "target/site").toURI() }</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>
+ <module>{ FileUtils.relativePath(buildFolder, scalaIDEFolder) }</module>
+ </modules>
+ </profile>
+ </profiles>
+ </project>
+ }
+
+ def createScalaIDEPomXml(scalaIDEVersion: ScalaIDEVersion, parentId: String) = {
+ // 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>
+ </parent>
+ <artifactId>org.scala-ide.ecosystem.generated{ artifactIdSuffix.next }</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>{ scalaIDEVersion.repository.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>
+ }
+
+ def createScalaIDESiteXml(scalaIDEVersion: ScalaIDEVersion) = {
+ <site>
+ { featureXml(Ecosystem.ScalaIDEFeatureId, scalaIDEVersion.version.toString, "sdt") }
+ { featureXml(Ecosystem.ScalaIDESourceFeatureId, scalaIDEVersion.version.toString, "sdt-source") }
+ { featureXml(Ecosystem.ScalaIDEDevFeatureId, scalaIDEVersion.version.toString, "dev") }
+ <category-def name="sdt" label="Scala IDE for Eclipse"/>
+ <category-def name="sdt-source" label="Scala IDE for Eclipse Source Feature"/>
+ <category-def name="dev" label="Scala IDE for Eclipse development support"/>
+ </site>
+ }
+
def createAddOnPomXml(addOn: AddOn, scalaIDEVersion: ScalaIDEVersion, parentId: String) = {
// 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">
@@ -238,8 +398,8 @@ object EcosystemBuildsMavenProjects {
</build>
</project>
}
-
- def createAddOnSiteXml(addOn: AddOn) = {
+
+ def createAddOnSiteXml(addOn: AddOn) = {
// TODO: fix category
// TODO: fix sourceFeatureId, should be option
<site>
@@ -250,11 +410,11 @@ object EcosystemBuildsMavenProjects {
<category-def name="source" label="Sources"/>
</site>
}
-
+
private def featureXml(id: String, version: String, category: String) = {
<feature url={ "features/" + id + "_0.0.0.jar" } id={ id } version={ version }>
<category name={ category }/>
</feature>
}
-
+
}
@@ -38,6 +38,7 @@ h4 {margin: 0.2em 0 0 0; margin-right: 3em;}
.scalaIDEVersion {margin-bottom: 0;}
.notAvailable {color: rgba(0, 0, 0, 0.5); text-shadow: none;}
+.zipped {font-weight: normal; font-style: italic; color: #404040;}
.red {color: red;}
.blue {color: blue;}
.outer {display: inline-block;}
@@ -61,7 +62,7 @@ h4 {margin: 0.2em 0 0 0; margin-right: 3em;}
</div>
{ builds.ecosystems.map(generate(_)) }
<div class="footer">
- generated: {timeStampPrettyPrinted}
+ generated:{ timeStampPrettyPrinted }
</div>
</span>
</body>
@@ -85,7 +86,7 @@ h4 {margin: 0.2em 0 0 0; margin-right: 3em;}
</div>
<div class="updatedEcosystem">
<h2>Updated ecosystem { rebuiltComment(build.regenerateEcosystem) }</h2>
- { build.baseScalaIDEVersions.map(scalaIDEVersionWithAddOns(_)) }
+ { build.baseScalaIDEVersions.map(s => scalaIDEVersionWithAddOns(s, build.zippedVersion.exists(_ == s))) }
</div>
{
if (build.nextScalaIDEVersions.isEmpty)
@@ -95,7 +96,7 @@ h4 {margin: 0.2em 0 0 0; margin-right: 3em;}
else
<div class="nextEcosystem">
<h2>Next ecosystem { rebuiltComment(build.regenerateNextEcosystem) }</h2>
- { build.nextScalaIDEVersions.map(scalaIDEVersionWithAddOns(_)) }
+ { build.nextScalaIDEVersions.map(scalaIDEVersionWithAddOns(_, false)) }
</div>
}
</div>
@@ -141,9 +142,9 @@ h4 {margin: 0.2em 0 0 0; margin-right: 3em;}
}
}
- def scalaIDEVersionWithAddOns(scalaIDEVersion: ScalaIDEVersion) = {
+ def scalaIDEVersionWithAddOns(scalaIDEVersion: ScalaIDEVersion, zipped: Boolean) = {
<div class="scalaIDEVersion">
- <h3>{ scalaIDEVersion.version }</h3>
+ <h3>{ scalaIDEVersion.version }{ if (zipped) <span class="zipped"> zipped</span> }</h3>
<div class="usedAddOns">
<h4>Existing add-ons</h4>
{
@@ -169,7 +170,7 @@ h4 {margin: 0.2em 0 0 0; margin-right: 3em;}
-&nbsp;{ addon.version }
</div>
}
-
+
private def timeStampPrettyPrinted = new SimpleDateFormat("yyyyMMdd-HHmm z").format(new Date())
}
Oops, something went wrong.

0 comments on commit 01b84c2

Please sign in to comment.