Skip to content

Commit

Permalink
Unzipping executables into task tempDir (#118)
Browse files Browse the repository at this point in the history
- some anti-virus does not like running executable in user dir
- regression for issue #28

Change-Id: I93b7d89d7daa831ef05a812f5a69fe0c1fea7a07
  • Loading branch information
ngyukman authored Nov 11, 2019
1 parent 9aefe54 commit 694dbb3
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 46 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# gradle-msbuild-plugin changelog

# 3.7
### Fixed
* Unzip binaries into temporaryDir of the task

# 3.6
### Added
* Support finding msbuild buildtools from VS2019 installation
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gradle MsBuild Plugin [![Build status](https://ci.appveyor.com/api/projects/status/dx29ov4txa120okx/branch/master?svg=true)](https://ci.appveyor.com/project/gluck/gradle-msbuild-plugin/branch/master) [![Build Status](https://travis-ci.org/Ullink/gradle-msbuild-plugin.svg?branch=master)](https://travis-ci.org/Ullink/gradle-msbuild-plugin)
# Gradle MsBuild Plugin [![Build status](https://ci.appveyor.com/api/projects/status/dx29ov4txa120okx/branch/master?svg=true)](https://ci.appveyor.com/project/gluck/gradle-msbuild-plugin/branch/master) [![Build Status](https://travis-ci.org/Itiviti/gradle-msbuild-plugin.svg?branch=master)](https://travis-ci.org/Itiviti/gradle-msbuild-plugin)

This plugin allows to compile an MsBuild project.
It also supports project file parsing, and some basic up-to-date checks to skip the build.
Expand All @@ -24,7 +24,7 @@ To apply the plugin:
```groovy
// Starting from gradle 2.1
plugins {
id 'com.ullink.msbuild' version '3.1'
id 'com.ullink.msbuild' version '3.7'
}
```

Expand All @@ -36,7 +36,7 @@ buildscript {
}
dependencies {
classpath 'com.ullink.gradle:gradle-msbuild-plugin:3.1'
classpath 'com.ullink.gradle:gradle-msbuild-plugin:3.7'
}
}
apply plugin:'com.ullink.msbuild'
Expand Down
23 changes: 7 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'nu.studer.plugindev' version '1.0.9'
id 'nu.studer.plugindev' version '1.0.12'
id 'com.jfrog.bintray' version '1.8.4'
id 'com.ullink.msbuild' version '3.1'
id 'com.ullink.nuget' version '2.15'
id 'com.ullink.nunit' version '1.13'
id 'com.ullink.msbuild' version '3.6'
id 'com.ullink.nuget' version '2.18'
id 'com.ullink.nunit' version '2.0'
id 'net.researchgate.release' version '2.6.0'
id 'de.undercouch.download' version '3.4.3'
}
Expand All @@ -25,10 +25,6 @@ dependencies {
compile 'com.google.guava:guava:27.0.1-jre'
}

nuget {
version = '4.4.0'
}

nugetRestore {
solutionFile = file('ProjectFileParser.sln')
}
Expand All @@ -41,10 +37,8 @@ msbuild {
}

nunit {
nunitVersion = '3.0.1'
testAssemblies = [ msbuild.projects['ProjectFileParser_Tests'].properties.TargetPath ]
}
nunit.dependsOn msbuild

task generateZip(dependsOn: nunit, type: Zip) {
from (msbuild.mainProject.properties.TargetDir) {
Expand All @@ -57,7 +51,7 @@ task generateZip(dependsOn: nunit, type: Zip) {
}

task downloadVsWhere(type: de.undercouch.gradle.tasks.download.Download) {
src 'https://github.com/Microsoft/vswhere/releases/download/2.6.7/vswhere.exe'
src 'https://github.com/Microsoft/vswhere/releases/download/2.8.4/vswhere.exe'
dest "$temporaryDir/vswhere.exe"
}

Expand All @@ -76,11 +70,8 @@ sourceSets {
}

bintray {
// to remove when upgraded plugindev to 1.0.4
user project.properties.bintrayUser
key project.properties.bintrayApiKey
pkg.repo = 'gradle-plugins'
pkg.userOrg = 'ullink'
pkg.userOrg = 'Itiviti'
pkg.version.gpg.sign = true
}

Expand All @@ -94,7 +85,7 @@ plugindev {
authorId 'gluck'
authorName 'Francois Valdy'
authorEmail 'francois.valdy@gmail.com'
projectUrl "https://github.com/Ullink/${project.name}"
projectUrl "https://github.com/Itiviti/${project.name}"
projectInceptionYear '2012'
done()
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-bin.zip
22 changes: 19 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down Expand Up @@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down
18 changes: 17 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
32 changes: 14 additions & 18 deletions src/main/groovy/com/ullink/Msbuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,24 @@ class Msbuild extends ConventionTask {
if (!file.exists()) {
throw new GradleException("Project/Solution file $file does not exist")
}
File tempDir = Files.createTempDirectory('ProjectFileParser').toFile()
tempDir.deleteOnExit()
File tempDir = Files.createTempDirectory(temporaryDir.toPath(), 'ProjectFileParser').toFile()

def zipFileStream = this.class.getResourceAsStream("/META-INF/ProjectFileParser.zip")
ZipInputStream zis = new ZipInputStream(zipFileStream)
ZipEntry ze = zis.getNextEntry()
while (ze != null) {
String fileName = ze.getName()
if (ze.isDirectory()) {
File subFolder = new File(tempDir, fileName)
subFolder.mkdir()
subFolder.deleteOnExit()
this.class.getResourceAsStream('/META-INF/ProjectFileParser.zip').withCloseable {
ZipInputStream zis = new ZipInputStream(it)
ZipEntry ze = zis.getNextEntry()
while (ze != null) {
String fileName = ze.getName()
if (ze.isDirectory()) {
File subFolder = new File(tempDir, fileName)
subFolder.mkdir()
ze = zis.getNextEntry()
continue
}
File target = new File(tempDir, fileName)
target.newOutputStream().leftShift(zis).close()
ze = zis.getNextEntry()
continue
}
File target = new File(tempDir, fileName)
target.newOutputStream().leftShift(zis).close()
target.deleteOnExit()
ze = zis.getNextEntry()
}
zis.closeEntry()
zis.close()

def executable = new File(tempDir, 'ProjectFileParser.exe')
def builder = resolver.executeDotNet(executable)
Expand Down
3 changes: 1 addition & 2 deletions src/main/groovy/com/ullink/MsbuildResolver.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class MsbuildResolver implements IExecutableResolver {

// Find msbuild >= 15.0 by vswhere
static def findMsbuildByVsWhere(Msbuild msbuild) {
File tempDir = Files.createTempDirectory('vswhere').toFile()
tempDir.deleteOnExit()
File tempDir = Files.createTempDirectory(msbuild.temporaryDir.toPath(), 'vswhere').toFile()

def vswhereFile = new File(tempDir, 'vwshere.exe')
Resources.asByteSource(MsbuildResolver.getResource("/vswhere.exe")).copyTo(com.google.common.io.Files.asByteSink(vswhereFile))
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/META-INF/gradle-plugins/msbuild.properties

This file was deleted.

0 comments on commit 694dbb3

Please sign in to comment.