This repository has been archived by the owner on May 9, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial Artifactrep Publication sbt plugin for new gu-deploy libr…
…aries.
- Loading branch information
1 parent
51ef6fc
commit ad1d06e
Showing
7 changed files
with
198 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
|
||
... | ||
} | ||
|
||
|
52 changes: 52 additions & 0 deletions
52
sbt-gu-deploy-artifactrep-publish/src/main/scala/com.gu.deploy/DistributableElements.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
sbt-gu-deploy-artifactrep-publish/src/main/scala/com.gu.deploy/PackagedWebapp.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
sbt-gu-deploy-artifactrep-publish/src/main/scala/com.gu.deploy/Preamble.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters