Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
Add initial Artifactrep Publication sbt plugin for new gu-deploy libr…
Browse files Browse the repository at this point in the history
…aries.
  • Loading branch information
daithiocrualaoich committed Feb 14, 2011
1 parent 51ef6fc commit ad1d06e
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 2 deletions.
4 changes: 3 additions & 1 deletion project/build/ManagementProject.scala
Expand Up @@ -11,7 +11,8 @@ class ManagementProject(info: ProjectInfo) extends ParentProject(info) {
lazy val versionInfoPlugin = project("sbt-version-info-plugin", "sbt-version-info-plugin", new VersionInfoPlugin(_))
lazy val packageDeployArtifactPlugin =
project("sbt-artifactrep-publish", "sbt-artifactrep-publish", new PublishToArtifactrepPlugin(_), versionInfoPlugin)

lazy val guDeployArtifactPlugin =
project("sbt-gu-deploy-artifactrep-publish", "sbt-gu-deploy-artifactrep-publish", new GuDeployPublishToArtifactrepPlugin(_), versionInfoPlugin)

class ManagementLift(info: ProjectInfo) extends DefaultProject(info) with PublishSources {
val liftWebkit = "net.liftweb" %% "lift-webkit" % "2.2" withSources()
Expand All @@ -23,6 +24,7 @@ class ManagementProject(info: ProjectInfo) extends ParentProject(info) {

class VersionInfoPlugin(info: ProjectInfo) extends PluginProject(info)
class PublishToArtifactrepPlugin(info: ProjectInfo) extends PluginProject(info)
class GuDeployPublishToArtifactrepPlugin(info: ProjectInfo) extends PluginProject(info)

override def managedStyle = ManagedStyle.Maven

Expand Down
@@ -1,4 +1,5 @@
import sbt._
import com.gu.versioninfo.VersionInfo

trait PackagedWebapp extends BasicWebScalaProject with MavenStyleWebScalaPaths with VersionInfo {
val deployCommon = "com.gu" % "deploy-common" % "1.35" % "runtime"
Expand Down
32 changes: 32 additions & 0 deletions sbt-gu-deploy-artifactrep-publish/README.md
@@ -0,0 +1,32 @@
SBT Guardian Plugin
===================
SBT plugin for custom Guardian build patterns.

Usage
=====
Plugins file:

import sbt._

class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val guardian = "Guardian GitHub" at "http://guardian.github.com/maven/repo-releases"
val gu = "com.gu" % "sbt-gu-plugin" % "0.1"
}


Project file:

import sbt._
import com.gu.solr.SolrProject

class MyProject(info: ProjectInfo) extends DefaultWebProject(info)
with ManifestProject {

// After SBT running with Scala > 2.8 :
// override def build = super.build.copy(artifact="content-api-custom", branch="release-101")
override def build = super.build.copy_("content-api-custom")

...
}


@@ -0,0 +1,52 @@
/*
Copyright 2010 Guardian News and Media
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.gu.deploy

import sbt._

abstract class DistributableElement {
protected def filter(simplePattern: String): NameFilter = GlobFilter(simplePattern)
def addToDistribution(where: Path, logger: Logger): Unit
}

case class DeploySupport(src: Path, deployLib: Path) extends DistributableElement {
override def addToDistribution(where: Path, logger: Logger) {
FileUtilities.copyDirectory(src, where / "deploy", logger)
FileUtilities.unzip(deployLib, where / "deploy", logger)
}
}

case class Paths(src: Path, application: String, to: String) extends DistributableElement {
override def addToDistribution(where: Path, logger: Logger) {
val paths = (src ##) ** filter("*")
FileUtilities.copy(paths.get, where / application / to, logger)
}
}

case class PathsFlat(src: Path, application: String) extends DistributableElement {
override def addToDistribution(where: Path, logger: Logger) {
val paths = (src ##) ** filter("*")
FileUtilities.copy(paths.get, where / application, logger)
}
}

case class WebApp(src: Path, application: String, warName: String) extends DistributableElement {
override def addToDistribution(where: Path, logger: Logger) {
FileUtilities.copyFile(src, where / application / "webapps" / warName, logger)
}
}
@@ -0,0 +1,66 @@
/*
Copyright 2010 Guardian News and Media
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.gu.deploy

import sbt._
import com.gu.versioninfo.VersionInfo
import com.gu.deploy.Preamble._

trait PackagedWebapp extends BasicWebScalaProject with VersionInfo {

val guardian_nexus = "Guardian Nexus" at "http://nexus.gudev.gnl:8081/nexus/content/groups/public"
def deployLibsVersion = "1.55"
val deployLibs = "com.gu" % "gu-deploy-libs" % deployLibsVersion % "runtime"

protected def artifact = projectName.value
protected def deployLibJar = this lib "gu-deploy-libs-*.jar"

private val distDir = outputPath / "dist"
private val distWorkingDir = distDir / "build"
private val artifactsDistName = "artifacts.zip"

private def artifactrep =
if (isDev) {
outputPath / "DEV" / "r2" / "ArtifactRepository"
} else {
Path fromFile "/r2/ArtifactRepository"
}

lazy val distOutputDir = artifactrep / artifact / "trunk" / buildName

def distributableElements: List[DistributableElement]

lazy val prepareDist = prepareDistAction dependsOn(`package`) describedAs "Lay out distribution folder"
def prepareDistAction = task {
FileUtilities.clean(distWorkingDir, log)
distributableElements foreach { _.addToDistribution(distWorkingDir, log) }

None
}

lazy val dist = distAction dependsOn (prepareDist) describedAs "Build artifact suitable for deployment"
def distAction = zipTask( (distWorkingDir ##) ***, distDir, artifactsDistName)

lazy val publishDist = publishDistAction dependsOn (dist) describedAs "Publish to artifact repository"
def publishDistAction = task {
FileUtilities.copyFile(distDir / artifactsDistName, distOutputDir / artifactsDistName, log)

None
}

}
@@ -0,0 +1,40 @@
/*
Copyright 2010 Guardian News and Media
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.gu.deploy

import sbt._

object Preamble {

implicit def pathFinder2head(finder: PathFinder) = new {
def head = finder.get.toList.head
}

implicit def project2Get(project: Project) = new {
def get(filePattern: String) = (project.outputPath ** project.filter(filePattern)).head
}

implicit def mavenStyleScalaPaths2src(project: MavenStyleScalaPaths) = new {
def src(filePattern: String) = (project.sourcePath ** project.filter(filePattern)).head
}

implicit def basicDependencyPaths2Lib(project: BasicDependencyPaths) = new {
def lib(filePattern: String) = (project.path(project.managedDirectoryName) ** project.filter(filePattern)).head
}

}
@@ -1,3 +1,5 @@
package com.gu.versioninfo

import java.net.InetAddress
import java.util.Date
import sbt._
Expand Down Expand Up @@ -29,5 +31,6 @@ trait VersionInfo extends BasicScalaProject {
}

override def compileAction = super.compileAction dependsOn generateVersion
}

def isDev = buildNumberString == "DEV"
}

0 comments on commit ad1d06e

Please sign in to comment.