Signing apk with maven-jarsigner-plugin - maven

I followed this tutorial and configured maven to sign my apk.
Here is a part of my pom.xml
<!-- Maven plugin which is responsible for signing apks -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
<goal>verify</goal>
</goals>
<phase>package</phase>
<inherited>true</inherited>
<configuration>
<removeExistingSignatures>true</removeExistingSignatures>
<archiveDirectory/>
<includes>
<include>${project.build.directory}/eticapp-1.0.0-SNAPSHOT.apk</include>
</includes>
<keystore>d:\My Docs\KeyStore\EtickAppKeystore</keystore>
<alias>ekey</alias>
<storepass>1234abcd</storepass>
<keypass>123abc</keypass>
<verbose>true</verbose>
<arguments>
<argument>-sigalg</argument><argument>MD5withRSA</argument>
<argument>-digestalg</argument><argument>SHA1</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Indeed when I am trying to execute the goals:
jarsigner:sign jarsigner:verify
I get an Exception about failing alias, which is clearly set.
Any solutions for that?
Failed to execute goal org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign (default-cli) on project eticapp: The parameters 'alias' for goal org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign are missing or invalid -> [Help 1]

The solution was not to use quotatin marks in my alias and password!

Related

Creating an Archetype From POM: Property is Missing

I created a Maven archetype and want to create an example project of it in my repository, which seems to be an unusual use-case.
Since I don't want to create the archetype manually, I added the following execution:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<configuration>
<archetypeGroupId>my.company.archetypes</archetypeGroupId>
<archetypeVersion>${project.version}</archetypeVersion>
<groupId>org.acme</groupId>
<version>0.1.2-SNAPSHOT</version>
<interactiveMode>false</interactiveMode>
</configuration>
<executions>
<execution>
<id>archetype-one</id>
<goals>
<goal>generate</goal>
</goals>
<phase>package</phase>
<configuration>
<archetypeArtifactId>archetype-one</archetypeArtifactId>
<artifactId>one</artifactId>
<package>org.acme.one</package>
</configuration>
</execution>
</executions>
</plugin>
This leads to the following exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (archetype-one) on project examples: Archetype my.company.archetypes:archetype-one:0.9.0-SNAPSHOT is not configured
[ERROR] Property groupId is missing.
[ERROR] Property artifactId is missing.
[ERROR] Property package is missing.
Which is just not true, since I've defined all of these. At least the IDE proposes these tags on that position. Moving the configuration tags around doesn't help either.
So I checked the source code of generate, and lo and behold, the target GAVs aren't present.
How do I define them when generating an archetype directly from another pom.xml?
So I ended up using an entirely different Maven plug-in:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>archetype-one</id>
<goals>
<goal>exec</goal>
</goals>
<phase>package</phase>
<configuration>
<executable>mvn</executable>>
<arguments>
<argument>archetype:generate</argument>
<argument>-DarchetypeGroupId=my.company.archetypes</argument>
<argument>-DarchetypeVersion=${project.version}</argument>
<argument>-DgroupId=org.acme</argument>
<argument>-Dversion=0.1.2-SNAPSHOT</argument>
<argument>-DinteractiveMode=false</argument>
<argument>-DarchetypeArtifactId=archetype-one</argument>
<argument>-DartifactId=one</argument>
<argument>-Dpackage=org.acme.one</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
And since I wanted to generate multiple archetypes, I put the first six arguments into a general <configuration> block, and appended the remaining three with <arguments combine.children="append">.

No schemas have been found | XJC

Can someone please help me on this issue. I have more than 2 schema files in the same directory and trying to generate the java classes using xjc in maven.
Here is my pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${jaxb2.version}</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<clearOutputDir>false</clearOutputDir>
<extension>true</extension>
<schemaFiles>${root.dir}/schemas/PnTCacheSchema.xsd</schemaFiles>
<schemaDirectory>${root.dir}/schemas/</schemaDirectory>
<packageName>com.superpages.nbt.gen.pnt</packageName>
<outputDirectory>${root.dir}/nbt/src</outputDirectory>
</configuration>
</execution>
<execution>
<id>xjc1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<clearOutputDir>false</clearOutputDir>
<extension>true</extension>
<schemaFiles>${root.dir}/schemas/AdCacheSchema.xsd</schemaFiles>
<schemaDirectory>${root.dir}/schemas/</schemaDirectory>
<packageName>com.superpages.nbt.gen.cache</packageName>
<outputDirectory>${root.dir}/nbt/src</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Getting this exception
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc (default-cli) on project gypsygen: No schemas have been found -> [Help 1]
Try enclosing <plugins> tag inside <pluginManagement> tag.

Override filename in maven when deploying file

I generate zip file in maven-assembly-plugin with specific name and want be able to deploy it.
I define $[my-version} property in initialize phase and I successfully get the file, but when deoplying I get the following error:
[ERROR]
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli)
on project my-project: C:\Users\pr\work\my-project\target\target\my-file-${my-version}.zip not found.
-> [Help 1]
Code:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<file>target/my-file-${my-version}.zip</file>
<repositoryId>releases</repositoryId>
<url>${nexus.url}/content/repositories/releases</url>
</configuration>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<finalName>my-file-${my-version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/deployment.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
The problem was in order of phases. When calling goal "deploy:deploy-file" directly, the phase "intialization" wasn't processed.
So, one of the ways is to call it explicitly:
mvn initialize deploy-file

does maven profile configured for integration phase execute during build life cycle?

Here is the condensed snippet of pom.xml from my project
<profiles>
<profile>
<id>run-tests</id>
<build>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
......
</includes>
<replacements>
<replacement>
.......
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
......
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<phase>integration-test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I have two questions:
1) when I execute mvn clean package -Prun-tests, what happens? I expected none of these plugin goals to execute here because they are bound to integration-test phase. But I see these goals executed why?
2) what does having two goals in execution block mean? please see above in failsafe-plugin
Thanks
A partial answer:
1) No Way. Unless you also have these plugins configured in the main build section to be run in phases up to package.
How did you determine that the plugins had run? Do you have something such as the following in the maven output?
[INFO] --- maven-failsafe-plugin:2.18.1:integration-test (default)
[INFO] --- maven-failsafe-plugin:2.18.1:verify (default)
2) That means that the two goals (mojos) will be executed in the integration-test phase. First the integration-test goal, immediately followed by the verify goal.
Comment: integration-test goal is by default bound to the integration-test phase, whereas the verify goal is bound to the verify phase. So you could have configured the failsafe plugin this way:
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
Note that the phase is ommited

How to resolve a Maven "The packaging for this project did not assign a file to the build artifact" error?

I’m using Maven 3.2.3. I used to be able to run “mvn clean install” on my WAR project and the WAR would get installed to my local repository. However, I recently added a configuration so that my WAR would be constructed in place (config is below). Now, when I run
mvn clean install
I get the error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install (install) on project myproject: The packaging for this project did not assign a file to the build artifact -> [Help 1]
How do I fix this? I tried making the “install” goal of the maven-install-plugin the default, but that didn’t help. Below is my Maven configuration …
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/src/main/webapp/WEB-INF/classes</directory>
</fileset>
<fileset>
<directory>${project.basedir}/src/main/webapp/WEB-INF/lib</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<useCache>true</useCache>
<workDirectory>/tmp/${project.artifactId}/war/work</workDirectory>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
</execution>
<execution>
<id>war-inplace</id>
<phase>package</phase>
<goals>
<goal>inplace</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
</execution>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
Adding the below rpm entry
%_rpmfilename noarch/%%{NAME}-%%{VERSION}-%%{RELEASE}.noarch.rpm
in each of the following files mentioned here solved the problem for me. (from 64 to no-arch).
vim /etc/rpm/macros
vim ~/.rpmmacros

Resources