Skip to content

Commit

Permalink
replacing google drive functionality with third party gradle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
warlordofmars committed Mar 15, 2019
1 parent 0f5621f commit cafa2b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 50 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
compile gradleApi()
compile 'com.github.warlordofmars:gradle-prerequisites-check:release-0.1.2'
compile 'com.github.warlordofmars:gradle-customtest-helper:release-0.1.9'
compile "gradle.plugin.ru.kinca.gradle:google-drive-uploader:1.1.0"
}

githubRelease.releaseAssets jar.archivePath
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import groovy.json.JsonSlurper
import groovy.json.JsonBuilder
import java.util.TimeZone
import java.io.ByteArrayOutputStream
import org.gradle.api.GradleException

import com.github.warlordofmars.gradle.resume.JSONResumeExtension

Expand All @@ -22,6 +23,7 @@ class JSONResumePlugin implements Plugin<Project> {
mExtension = project.extensions.create('resume', JSONResumeExtension)

project.plugins.apply('com.github.warlordofmars.gradle.prerequisites')
project.plugins.apply('ru.kinca.google-drive-uploader')
project.rootProject.plugins.apply('com.github.warlordofmars.gradle.customtest')

project.afterEvaluate {
Expand All @@ -32,7 +34,6 @@ class JSONResumePlugin implements Plugin<Project> {

ensureStringsTest: [mExtension.resumeSource, 'Expected Strings Found in Deployed HTML Resume'],
resumeDeployedWebTest: [mExtension.resumeSource, 'Deployed Resumes Are Web Accessible'],
resumeDeployedGoogleTest: [mExtension.resumeSource, 'Resume Deployed to Google Drive'],
resumeDeployedAppleTest: [mExtension.resumeSource, 'Resume Deployed to iCloud Drive'],

ensureStringsProdTest: [mExtension.resumeSource, 'Expected Strings Found in Deployed HTML Resume in Production'],
Expand All @@ -48,14 +49,11 @@ class JSONResumePlugin implements Plugin<Project> {

]


project.ext.prerequisites << [
'hackmyresume': 'Install via \'npm install -g hackmyresume\'',
'aspell': 'Install via \'brew install aspell\'',
'lp': 'This is a built-in that should already be there. Why isn\'t it there?',
'aws': 'Install via \'brew install awscli\'',
'wkhtmltopdf': 'Install via \'brew install wkhtmltopdf\'',
'gdrive': 'Install via \'brew install gdrive\'',
]


Expand Down Expand Up @@ -265,42 +263,18 @@ class JSONResumePlugin implements Plugin<Project> {
}
}

project.googleDrive {
destinationFolderPath = mExtension.isPromote ? "/" : "resume-v${project.rootProject.version}"
file = project.file("${project.buildDir}/resume.pdf")
clientId = project.getProperty('google.api.client_id')
clientSecret = project.getProperty('google.api.client_secret')
}

project.task('publishResumeToGoogle') {
description 'Publish pdf resume to Google Drive'
group TASK_GROUP
mustRunAfter project.build
dependsOn project.checkPrerequisites
doLast {

def out = new ByteArrayOutputStream()
project.exec {
commandLine 'gdrive', 'list', '--no-header', '-q', "name = 'resume.v${project.rootProject.version}.pdf'"
standardOutput out
}

out.toString().readLines().each {
def fileId = it.split(" ")[0]
project.exec {
commandLine 'gdrive', 'delete', fileId
}
}

project.exec {
commandLine 'gdrive', 'upload', '--name', "resume.v${project.rootProject.version}.pdf", "${project.buildDir}/resume.pdf"
}

if(mExtension.isPromote) {
def out2 = new ByteArrayOutputStream()
project.exec {
commandLine 'gdrive', 'list', '--no-header', '-q', 'name = "resume.pdf"'
standardOutput out2
}
def fileId = out2.toString().split(" ")[0]
project.exec {
commandLine 'gdrive', 'update', fileId, "${project.buildDir}/resume.pdf"
}
}
}
dependsOn project.uploadToDrive
}

project.task('publishResumeToApple') {
Expand Down Expand Up @@ -329,15 +303,13 @@ class JSONResumePlugin implements Plugin<Project> {

def ensureStringsTestObj = project.rootProject.ensureStringsTest
def resumeDeployedWebTestObj = project.rootProject.resumeDeployedWebTest
def resumeDeployedGoogleTestObj = project.rootProject.resumeDeployedGoogleTest
def resumeDeployedAppleTestObj = project.rootProject.resumeDeployedAppleTest

def resumeFileName = "resume.v${project.rootProject.version}.pdf"

if(mExtension.isPromote) {
ensureStringsTestObj = project.rootProject.ensureStringsProdTest
resumeDeployedWebTestObj = project.rootProject.resumeDeployedWebProdTest
resumeDeployedGoogleTestObj = project.rootProject.resumeDeployedGoogleProdTest
resumeDeployedAppleTestObj = project.rootProject.resumeDeployedAppleProdTest
resumeFileName = 'resume.pdf'
}
Expand Down Expand Up @@ -365,18 +337,6 @@ class JSONResumePlugin implements Plugin<Project> {
}
resumeDeployedWebTestObj.success("All resume formats have been deployed successfully and are currently web-accessible at the following URLs:\n\n${urlList.join('\n')}")

def out = new ByteArrayOutputStream()
project.exec {
commandLine 'gdrive', 'list', '--no-header', '-q', "name = '${resumeFileName}'"
standardOutput out
}

if(out.toString().split(" ").size() > 1) {
resumeDeployedGoogleTestObj.success("${resumeFileName} is available in Google Drive")
} else {
resumeDeployedGoogleTestObj.failure('Resume Not Found in Google Drive', "${resumeFileName} is not found in Google Drive")
}


if(project.file("${iCloudLocalDir}/resume.v${project.rootProject.version}.pdf").exists()) {
resumeDeployedAppleTestObj.success("${resumeFileName} is available in iCloud Drive")
Expand Down

0 comments on commit cafa2b6

Please sign in to comment.