Code Monkey home page Code Monkey logo

Comments (16)

ebourg avatar ebourg commented on August 27, 2024 2

This looks fairly complex, and I don't think a build script is the right place to write code, it's sad that Gradle encourages this. Using the Ant task should be easier:

configurations {
    jsign
}

dependencies {
    jsign group: 'net.jsign', name: 'jsign', version: '1.3'
}

task jsign << {
    ant.taskdef(name: 'jsign', classname: 'net.jsign.PESignerTask', classpath: configurations.jsign.asPath)
    ant.jsign(file: 'application.exe',
              name: 'My Application',
              url:  'http://www.example.com',
              keystore: 'keystore.p12',
              alias: 'test',
              storepass: 'secret',
              tsaurl: 'http://timestamp.comodoca.com/authenticode')
}

from jsign.

ebourg avatar ebourg commented on August 27, 2024

Integrating an Ant task with Gradle is quite easy and for now I don't plan to implement a Gradle plugin. But if someone wants to write one I'd be happy to merge it.

from jsign.

nedtwigg avatar nedtwigg commented on August 27, 2024

I'm not sure a gradle plugin could be much simpler than just calling out to PESigner directly. Here's how I do it:

task sign {
    doLast {
        PESigner signer = new PESigner(INSTALLER_FILE)
        signer.setArg('name', 'MyApp')
        signer.setArg('url', 'https://myapp.com')
        ...
        signer.sign()
    }
}

from jsign.

dmodoomsirius avatar dmodoomsirius commented on August 27, 2024

is the installer file the actual jsign file? just getting back to this now. thanks for the info.

from jsign.

nedtwigg avatar nedtwigg commented on August 27, 2024

INSTALLER_FILE is the file you want to sign. In my case, it's an .exe. Not sure what a jsign file is.

from jsign.

dmodoomsirius avatar dmodoomsirius commented on August 27, 2024

http://search.maven.org/#artifactdetails%7Cnet.jsign%7Cjsign%7C1.3%7Cjar this file is what i was referencing.

from jsign.

nedtwigg avatar nedtwigg commented on August 27, 2024

Gotcha. You add that to your buildscript by putting this at the top of your buildscript:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "net.jsign:jsign:1.3"
    }
}

import net.jsign.PESigner

from jsign.

dmodoomsirius avatar dmodoomsirius commented on August 27, 2024
:launcher-bootstrap:signexe FAILED

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Myahm\Desktop\coding\git\MC\github\oblivion\Launcher\launcher-bootstrap\build.gradle' line: 71

* What went wrong:
Execution failed for task ':launcher-bootstrap:signexe'.
> Could not find matching constructor for: net.jsign.PESigner(java.lang.String)

I am dealing with a multi project setup when i run that it fails due to that.

from jsign.

nedtwigg avatar nedtwigg commented on August 27, 2024

Whoops, sorry. Looks like we actually have a little in-house code.

import net.jsign.PESignerCLI;

public class PESigner {
	private final File fileToSign;
	private final Map<String, String> stringProps = Maps.newHashMap();

	public PESigner(File fileToSign) {
		this.fileToSign = fileToSign;
	}

	public void setArg(String key, String value) {
		stringProps.put(key, value);
	}

	public void sign() {
		List<String> args = Lists.newArrayList();
		for (Map.Entry<String, String> entry : stringProps.entrySet()) {
			args.add("--" + entry.getKey());
			args.add(entry.getValue());
		}
		args.add(fileToSign.getAbsolutePath());
		PESignerCLI.main(args.toArray(new String[args.size()]));
	}
}

from jsign.

dmodoomsirius avatar dmodoomsirius commented on August 27, 2024

https://gist.github.com/dmodoomsirius/ba96f9c98283bf63fa94bb79acc2801a

^ my build.gradle for the project that has the exe i am trying to sign.

:launcher-bootstrap:signexe FAILED

FAILURE: Build failed with an exception.

* Where:
Build file '%userprofile%\Desktop\coding\git\MC\github\oblivion\Launcher\launcher-bootstrap\build.gradle' line: 95

* What went wrong:
Execution failed for task ':launcher-bootstrap:signexe'.
> Could not find matching constructor for: PESigner(java.lang.String)

from jsign.

nedtwigg avatar nedtwigg commented on August 27, 2024

If you know how to use buildSrc, then put the PESigner I copy-pasted above into it. If you don't, try something like this:

import net.jsign.PESignerCLI;

task sign {
    doLast {
        args = ['--arg', 'argValue', 'C:\PathToFileToSign']
        PESignerCLI.main(args.toArray(new String[args.size()]));
    }
}

from jsign.

dmodoomsirius avatar dmodoomsirius commented on August 27, 2024

I don't atm. I am looking into it right now.

from jsign.

dmodoomsirius avatar dmodoomsirius commented on August 27, 2024

Now I have can't read private key even tho I converted a PuttyGEN Key into a pvk using this tool. not sure what I am doing wrong.

from jsign.

dmodoomsirius avatar dmodoomsirius commented on August 27, 2024

Edit: moved issue to another issue. #34

from jsign.

ebourg avatar ebourg commented on August 27, 2024

I added a native Gradle plugin, please give it a try. Here is a usage example:

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')
}

I plan to upload the plugin to the Gradle Plugin Portal once the next version is released. The usage will then be easier :

plugins {
    id "net.jsign" version "1.4"
}

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')
}

from jsign.

dmodoomsirius avatar dmodoomsirius commented on August 27, 2024

ohh thank you. I will sure to give this a try when i get home.

from jsign.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.