4

I need to sign the released jars and I want to do it with the maven jarsigner plugin. So I added it like this:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jarsigner-plugin</artifactId>
            <version>1.2</version>
            <configuration>
                <archive>target/${myarchive}.jar</archive>
                <keystore>${key.location}</keystore>
                <storepass>${keypass}</storepass>
                <alias>${key.alias}</alias>
                <verbose>true</verbose>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>sign</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

I provide the missing parameters in command line.

When I run mvn install everything works fine and the archive is got signed. But when I run release:prepare release:perform the jarsigner plugin fails: `The parameters 'alias' for goal org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign are missing or invalid'

When I run in debug mode, I see the following:

For mvn install:

[DEBUG] Configuring mojo org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign from plugin realm ClassRealm[plugin>org.apache.m
aven.plugins:maven-jarsigner-plugin:1.2, parent: sun.misc.Launcher$AppClassLoader@6d6f0472]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign' with basic configurator -->
[DEBUG]   (f) alias = myalias
[DEBUG]   (f) archive = myarchive
[DEBUG]   (f) arguments = []
[DEBUG]   (f) keystore = mykeystore
[DEBUG]   (f) processAttachedArtifacts = true
[DEBUG]   (f) processMainArtifact = true
[DEBUG]   (f) project = MavenProject: com.playtech.chat:ums_supportchatapplet:12.4-SNAPSHOT @ *********\pom.xml
[DEBUG]   (f) removeExistingSignatures = false
[DEBUG]   (f) skip = false
[DEBUG]   (f) storepass = changeit
[DEBUG]   (f) verbose = true
[DEBUG] -- end configuration --

But when I run release:prepare release:perform, I see:

Configuring mojo org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-jarsigner-plugin:1.2, parent: sun.misc.Launcher$AppClassLoader@553f5d07]
[INFO] [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign' with basic configurator -->
[INFO] [DEBUG]   (f) archive = myarchive
[INFO] [DEBUG]   (f) arguments = []
[INFO] [DEBUG]   (f) processAttachedArtifacts = true
[INFO] [DEBUG]   (f) processMainArtifact = true
[INFO] [DEBUG]   (f) project = MavenProject: com.playtech.chat:ums_supportchatapplet:12.4.0.1 @ *****\pom.xml
[INFO] [DEBUG]   (f) removeExistingSignatures = false
[INFO] [DEBUG]   (f) skip = false
[INFO] [DEBUG]   (f) verbose = true
[INFO] [DEBUG] -- end configuration --

So except of archive property, other properties are ignored during the release.

Any ideas are highly appreciated.

Tarlog
  • 10,024
  • 2
  • 43
  • 67

2 Answers2

5

Found the answer.

In short -D arguments are not passed from the command line to the release plugin.
-Darguments= should be used.

For more details please read this blog post that helped me to resolve this issue.

Tarlog
  • 10,024
  • 2
  • 43
  • 67
1

Enter this command at the cmd prompt:

keytool -list -keystore [keystore location here]

Is the 'myalias' alias in that specific keystore? If not you'll need to create one.

The only other thing that I can see that could go wrong is if the password is incorrect for that keystore.

alex.p
  • 2,627
  • 17
  • 28
  • Did you read the whole question? Did you see that in the second case password is not getting passed at all to the plugin? Neither alias does? – Tarlog May 22 '12 at 10:40
  • You mentioned at the end of your question 'Any ideas are highly appreciated' obviously they're not appreciated as you feel compelled to downvote any such ideas. How do I know you haven't already created an alias in your keystore? Have some manners for people that are trying to help it's already an effort to understand your poor English. – alex.p May 22 '12 at 10:53
  • Another idea which you'll probably downvote if I give as an answer is that the execution of your plugin is in the package phase. Are the release:prepare release:perform goals downstream of the package phase? If not the plugin is never going to get executed. Which explains why your install works. – alex.p May 22 '12 at 10:56
  • Any related ideas. Not just some ideas that happen to pass in your head. If you were reading the whole question, you would see that usually it works, but it doesn't during the release, so the keystore must be fine. – Tarlog May 22 '12 at 10:58
  • The plugin is executed. Otherwise it was not failing. It even prints the debug information and I put it in the original question. – Tarlog May 22 '12 at 10:59
  • Regarding downvoting: If the answer is not useful, it's being downvoted. Your answers show that you didn't read the question. – Tarlog May 22 '12 at 11:03
  • And I understand that you have downvoted my question as a revenge. But do you really think that it does not show a research effort or is not useful? I guess not. So it's a revenge and let be it. I cannot care less. – Tarlog May 22 '12 at 11:06
  • Ideas that pass in someone's head may well be the answer - and it certainly is related; having an alias in the keystore is certainly related to the jar signer - as an alias is required for it to function. I can see you're annoyed and it seems the more ideas I pass to you the more annoyed you get - not the kind of action you should seek against someone there to help. Again I tell you to have some manners - it seems you downvoted in anger - nothing to do with whether my answer was unrelated - as it was related. My downvote was not in revenge just as your down vote was not in anger. – alex.p May 22 '12 at 11:20