'gpg2' is not recognized as an internal or external command - java

I use the maven-gpg-plugin in linux all is okay I can install the gpg2 for sign but in windows there is a problem with deploying.
There is log 'gpg2' is not recognized as an internal or external command,
operable program or batch file. (The same I get for gpg2 --version)
And
Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.5:sign (sign-artifacts) on project.
How can I install gpg2 for windows?

In you settings.xml file, change the gpg.executable property. Example.
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>PASSPHRASE</gpg.passphrase>
</properties>
</profile>
</profiles>

Related

How to use maven profile based on the IntelliJ profile?

I would like to activate maven profile based on the IntelliJ profile I select. I need to use different dependency when running the app locally and when deploying it to server.
I have these two profiles which select correct version of TimesTen, I would like to use "local" profile when testing the app locally in IntelliJ and the "server" profile when building the app.
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<org.timesten.version>6</org.timesten.version>
</properties>
</profile>
<profile>
<id>server</id>
<properties>
<org.timesten.version>11</org.timesten.version>
</properties>
</profile>
</profiles>
These are my IntelliJ profiles:

Maven Profile reads data from Properties file

I have a Selenium project which uses Maven as a build tool and I want to read different environment details (protocol, domain, subdomain, etc) from a .properties file. Would it be possible to use Maven profiles in order to run my tests on different environments such as dev, staging, prod based on the profile which I am specifying when triggering the mvn command?
dev.properties:
protocol=http
domain=domain.com
subdomain=www
pom.xml:
<profiles>
<profile>
<id>prod</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>pre_prod</id>
</profile>
<profile>
<id>dev</id>
</profile>
</profiles>
mvn:
mvn clean test -Pdev
Data should then be retrieved in the java code using
System.getProperty("protocol");
System.getProperty("domain");
System.getProperty("subdomain");
Any help would be very much appreciated.
Thanks!
If you just want to read different properties files based on a command line argument, could you not just pass in a string for example -Denv=dev
Then in your properties reader class have it init the properties file based on System.getProperty("env");
Properties generalProperties = new Properties();
String generalPropertiesFileName = "data/"+
System.getProperty("env") + ".properties";
initProperties(generalProperties, generalPropertiesFileName);
Alternatively you can also pass properties from the command line to your POM in the same way -
<properties>
<property>
<protocol></protocol>
<domain></domain>
<subdomain></subdomain>
<property>
<properties>
And then these can be passed in from the command line as -Dprotocol=foo etc
Hope that helps?

Maven build for Spring boot Application for windows and linux platforms

I need to generate my spring boot application binaries for windows and linux platforms using Maven build.
I am planning to have two different application.properties for windows and linux i.e
application-windows.properties
application-linux.properties
and in the pom.xml I will have this
<profile>
<id>dev</id>
<properties>
<activatedProperties>windows</activatedProperties>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>release</id>
<properties>
<activatedProperties>linux</activatedProperties>
</properties>
</profile>
Maven build will be triggered using Jenkins.But in this way I can have only one profile active at a time,So It will require two jenkins project for windows and linux.
Is there any better way of doing this?
Profile should be chosen by giving build argument while starting the spring boot application.
-Dspring.profles.active=$profile
If you are using jenkins to start the application , just add an option to choose profile during job execution which can add parameter to application.
https://docs.spring.io/spring-boot/docs/1.1.6.RELEASE/reference/html/boot-features-profiles.html

IntelliJ: activate Maven profile when running Junit tests

I have declared some properties that are specific to Maven profiles. A part of my pom.xml:
<profiles>
<profile>
<id>release</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<my.properties.file>foo.xml</my.properties.file>
</properties>
</profile>
<profile>
<id>ci</id>
<properties>
<my.properties.file>bar.xml</my.properties.file>
</properties>
</profile>
</profiles>
I encounter some problem to use the "ci" Maven profile when I start Junit tests via IntelliJ IDEA 2016.
I activate my profile via the "Maven Projects" panel, then I start tests. The problem is the "my.properties.file" property value is equal to "foo.xml", not "bar.xml".
I have no problem with command-line (I can use the "-Pci" flag). How can I tell IntelliJ to use the "ci" profile? Thx.
You should add the profiles to the Maven setting.xml file (you should find it in the path ${YOUR_MAVEN_HOME}\apache-maven-3.1.1\conf\setting.xml).
Then, you have to open intellij, click on View > Tool Windows > Maven Projects. There, you should see your profiles (ci and release) and select the correct one.
Hope this can help you.
Just finally solved it.
<profile>
<id>profile-to-be-activated-on-build</id>
<activation>
<activeByDefault>false</activeByDefault><!-- on your flavor -->
<property>
<name>mvn-profile-env-var-trigger</name>
</property>
</activation>
</profile>
Goto JUnit default profile (aka configuration template). Add into JVM args:
-Dmvn-profile-env-var-trigger
You may need to manually reload maven profiles in IDE.
Also make sure on [Settings > Build Tools > Maven > Running tests] envVars is checked (or better everything).

Include a Jar in Maven Project based on Operating System

I'm using a third party software in my Maven Project. The API calls are same for both Windows and Mac OS but the JAR files are different. Is there a way to identify the operating system at run-time and load appropriate jar from my lib folder in a Maven Project ? I want to be able to provide this final executable Jar to my client who may use my final Jar in an Windows or Mac OS and should be able to work on it by including my Jar in his project. For now, my client is including the Jar in his class path which seems as a horrible way of doing.
It could be nicely done by using Maven profiles and activation feature
<profiles>
<profile>
<id>windows-x86_64</id>
<activation>
<os>
<family>windows</family>
<arch>amd64</arch>
</os>
</activation>
</profile>
<profile>
<id>windows-x86</id>
<activation>
<os>
<family>windows</family>
<arch>x86</arch>
</os>
</activation>
</profile>
In this profiles you could set up custom properties, custom dependencies, etc.
Likely you need Maven NAR Plugin or may be use profiles depending on the actual content of system-specific parts

Categories

Resources