Skip to content

Commit

Permalink
GMOD#956 - uses bower to install jbrowse
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandunn committed Mar 30, 2016
1 parent 5738afc commit abd156a
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 6 deletions.
12 changes: 12 additions & 0 deletions apollo
Expand Up @@ -34,6 +34,7 @@ function deploy_message(){
echo "***************************************"
}


function check_node(){
node_executable=$(which node)
if ! [ -x "$node_executable" ] ; then
Expand All @@ -48,6 +49,17 @@ function check_node(){
fi
}

function check_bower(){
bower_executable=$(which bower)
if ! [ -x "$bower_executable" ] ; then
$node_executable install -g bower
if ! [ -x "$bower_executable" ] ; then
echo "You must install 'Bower' to do a release of Apollo."
exit 1 ;
fi
fi
}

function check_perldependencies(){
perl -e 'use Text::Markdown'
if [ $? != 0 ] ; then
Expand Down
97 changes: 93 additions & 4 deletions build.gradle
Expand Up @@ -2,7 +2,10 @@
//import java.util.zip.ZipInputStream
//import groovy.io.FileType
//import com.google.javascript.jscomp.*
import org.gradle.api.tasks.Exec
import org.apache.tools.ant.taskdefs.condition.Os

//defaultTasks 'bower'

/*
* This build file was auto generated by running the Gradle 'init' task
Expand Down Expand Up @@ -34,6 +37,12 @@ repositories {
}


ext {
npmCommand = Os.isFamily(Os.FAMILY_WINDOWS) ? 'npm.cmd' : 'npm'
bowerCommand = Os.isFamily(Os.FAMILY_WINDOWS) ? 'bower.cmd' : 'bower'
githubURL = "https://github.com/"
}


ant.importBuild 'build.xml'

Expand Down Expand Up @@ -101,7 +110,7 @@ task installJBrowse(dependsOn: evaluateJBrowseConfigs) << {
if (jbrowseConfig.git) {
def git = jbrowseConfig.git
if (jbrowseFile.exists()) {
if (git.alwaysRecheck || git.alwaysPull) {
if (git.alwaysRecheck || git.alwaysPull && !hasBower()) {
if (git.tag) {
fetchTags(jbrowseFile)
checkoutBranch(jbrowseFile, "tags/" + git.tag)
Expand All @@ -118,7 +127,7 @@ task installJBrowse(dependsOn: evaluateJBrowseConfigs) << {
println "Cloning: ${git.url} into ${jbrowseDirectory}."
def branch = git.branch ?: (git.tag ? "tags/${git.tag}" : null)
cloneRepo(git.url, jbrowseDirectory, branch, 1)
checkoutBranch(jbrowseFile, branch)
if(!hasBower()) checkoutBranch(jbrowseFile, branch)
}
} else if (jbrowseConfig.url && !jbrowseFile.exists()) {

Expand Down Expand Up @@ -156,7 +165,6 @@ task copyApolloPlugin(dependsOn:installJBrowse,type:Copy){
println "Copying apollo plugin"
from("client/apollo")
into("jbrowse-download/plugins/WebApollo")

}

task setupJBrowse(dependsOn: "setup-jbrowse") << {}
Expand Down Expand Up @@ -270,7 +278,7 @@ def cloneRepo(String url, String directory, String branch) {
cloneRepo(url, directory, branch, null)
}

def cloneRepo(String url, String directory, String branch, Integer depth) {
def cloneRepoNoBower(String url, String directory, String branch, Integer depth) {
String depthString = depth != null && depth > 0 ? " --recursive --depth ${depth} " : ""
def commandToExecute = "git clone ${depthString} ${url} ${directory} "
println "command to execute [${commandToExecute}]"
Expand All @@ -287,6 +295,87 @@ def cloneRepo(String url, String directory, String branch, Integer depth) {
checkoutBranch(new File(directory), branch)
}

Boolean hasBower(){
return true
}

task removeJBrowseDownload(type:Delete){
delete("jbrowse-download")
}

task moveBowerJBrowse(dependsOn:removeJBrowseDownload) {
doLast {
file("bower_components/jbrowse").renameTo(file("jbrowse-download"))
file("bower_components").deleteDir()
}
}

task installJBrowseBower(type:Exec) {
workingDir 'jbrowse-download'
commandLine './setup.sh'
}

def cloneRepoBower(String url,String directory,String branch){
String finalUrl = url + "#${branch}"
if(finalUrl.startsWith(githubURL)){
finalUrl = finalUrl.substring(githubURL.length())
}
exec{
println "using bower to install: ${finalUrl}"
commandLine "bower","install",finalUrl
// if(finalUrl.split("#")[0].endsWith("jbrowse")){
// mv bower_components/jbrowse -> jbrowse-download
// }
// installs it in bower_components
}

if(!(finalUrl.contains("#")&&finalUrl.endsWith("jbrowse")) || finalUrl.split("#")[0].endsWith("jbrowse")) {
tasks.moveBowerJBrowse.execute()
tasks.installJBrowseBower.execute()
}
}


// Get the path for the locally installed binaries
task npmBin << {
new ByteArrayOutputStream().withStream { os ->
exec {
executable = npmCommand
args = ['bin']
standardOutput = os
}
ext.binPath = os.toString().trim() + File.separator
}
}


// Install packages from package.json
task npm(type: Exec) {
description = "Grab NodeJS dependencies (from package.json)"
commandLine = [npmCommand, "install"]
inputs.file "package.json"
outputs.dir "node_modules"

tasks.npmBin.execute()

}


// Install the bower components for front-end library management
task bower(dependsOn: 'npm', type: Exec){
commandLine "${npmBin.binPath}${bowerCommand}", 'install'
}


def cloneRepo(String url, String directory, String branch, Integer depth) {
if(hasBower()){
cloneRepoBower(url,directory,branch)
}
else{
cloneRepoNoBower(url,directory,branch,depth)
}
}

def fetchTags(File file) {
println "fetching tags"
def processBuilder = new ProcessBuilder()
Expand Down
4 changes: 2 additions & 2 deletions grails-app/conf/Config.groovy
Expand Up @@ -348,8 +348,8 @@ auditLog {
jbrowse {
git {
url= "https://github.com/GMOD/jbrowse"
tag = "1.12.1-release"
// branch = "master"
// tag = "1.12.1-release"
branch = "yeban-bowerise"
alwaysPull = false
alwaysRecheck = false
}
Expand Down

0 comments on commit abd156a

Please sign in to comment.