Skip to content

Commit

Permalink
Added a Gradle plugin (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebourg committed Feb 22, 2017
1 parent cca6c57 commit b632516
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -2,6 +2,8 @@
*.ipr
*.iws
target/
/jsign-gradle-plugin/.gradle
/jsign-gradle-plugin/build

# eclipse files
/.settings
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -37,7 +37,7 @@ Version 1.4 (in development)
* Fixed the Accept header for RFC 3161 requests (contributed by Markus Kilås)
* Internal refactoring to share the code between the Ant task and the CLI tool (contributed by Michael Peterson)
* The code has been split into distinct modules (core, ant, cli).
* Jsign is now available as a Maven plugin (net.jsign:jsign-maven-plugin)
* Jsign is now available as a plugin for Maven (net.jsign:jsign-maven-plugin) and Gradle
* The API can be used to sign in-memory files using a SeekableByteChannel

Version 1.3, 2016-08-04
Expand Down
38 changes: 38 additions & 0 deletions jsign-gradle-plugin/build.gradle
@@ -0,0 +1,38 @@
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.gradle.publish:plugin-publish-plugin:0.9.7"
}
}

apply plugin: "java"
apply plugin: "com.gradle.plugin-publish"

repositories {
mavenLocal()
}

dependencies {
compile gradleApi()
compile 'net.jsign:jsign-core:1.4-SNAPSHOT'
}

pluginBundle {
website = 'https://ebourg.github.io/jsign/'
vcsUrl = 'https://github.com/ebourg/jsign'

description = 'Code signing for Windows executables'

plugins {
jsignPlugin {
id = 'net.jsign'
displayName = 'Gradle Jsign plugin'
tags = ['signing']
version = '1.4-SNAPSHOT'
}
}
}
21 changes: 21 additions & 0 deletions jsign-gradle-plugin/example.gradle
@@ -0,0 +1,21 @@
buildscript {
repositories {
mavenLocal()
}

dependencies {
classpath 'net.jsign:jsign-gradle-plugin:1.4-SNAPSHOT'
}
}

apply plugin: 'net.jsign'

task sign << {
signexe(file : 'application.exe',
name : 'My Application',
url : 'http://www.example.com',
keystore : 'keystore.p12',
alias : 'test',
storepass : 'secret',
tsaurl : 'http://timestamp.comodoca.com/authenticode')
}
69 changes: 69 additions & 0 deletions jsign-gradle-plugin/pom.xml
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.jsign</groupId>
<artifactId>jsign-gradle-plugin</artifactId>
<parent>
<groupId>net.jsign</groupId>
<artifactId>jsign-parent</artifactId>
<version>1.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>Jsign - Code signing for Windows executables (Gradle Plugin)</name>
<version>1.4-SNAPSHOT</version>
<packaging>jar</packaging>

<inceptionYear>2017</inceptionYear>

<description>
Pure Java implementation of Microsoft Authenticode for signing Windows executable files
</description>
<url>http://ebourg.github.com/jsign</url>

<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<repositories>
<repository>
<id>gradle-repository</id>
<url>http://repo.gradle.org/gradle/libs-releases-local</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<properties>
<gradle.version>3.4</gradle.version>
</properties>

<dependencies>
<dependency>
<groupId>net.jsign</groupId>
<artifactId>jsign-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.7</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-core</artifactId>
<version>${gradle.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
55 changes: 55 additions & 0 deletions jsign-gradle-plugin/src/main/java/net/jsign/GradleConsole.java
@@ -0,0 +1,55 @@
/**
* Copyright 2017 Emmanuel Bourg
*
* 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 net.jsign;

import org.gradle.api.logging.LogLevel;
import org.gradle.api.logging.Logger;

/**
* Console implementation for Gradle.
*
* @author Emmanuel Bourg
* @since 1.4
*/
public class GradleConsole implements Console {

private final Logger log;

public GradleConsole(Logger log) {
this.log = log;
}

@Override
public void debug(String message) {
log.debug(message);
}

@Override
public void info(String message) {
log.info(message);
}

@Override
public void warn(String message) {
warn(message, null);
}

@Override
public void warn(String message, Throwable t) {
log.log(LogLevel.WARN, message, t);
}
}
@@ -0,0 +1,49 @@
/**
* Copyright 2017 Emmanuel Bourg
*
* 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 net.jsign;

import java.io.File;
import java.util.Map;

import groovy.lang.Closure;
import org.gradle.api.Plugin;
import org.gradle.api.Project;

/**
* Gradle plugin registering the signexe extension method with the project.
*
* @author Emmanuel Bourg
* @since 1.4
*/
public class PESignerGradlePlugin implements Plugin<Project> {

@Override
public void apply(final Project project) {
project.getExtensions().add("signexe", new Closure(null) {
public void doCall(Map<String, String> params) throws SignerException {
String file = params.get("file");
params.remove("file");

PESignerHelper helper = new PESignerHelper(new GradleConsole(project.getLogger()), "property");
for (Map.Entry<String, String> param : params.entrySet()) {
helper.param(param.getKey(), param.getValue());
}
helper.sign(new File(file));
}
});
}
}
@@ -0,0 +1 @@
implementation-class=net.jsign.PESignerGradlePlugin
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -57,6 +57,7 @@
<module>jsign-cli</module>
<module>jsign</module>
<module>jsign-maven-plugin</module>
<module>jsign-gradle-plugin</module>
</modules>

<dependencies>
Expand Down

0 comments on commit b632516

Please sign in to comment.