swagger maven plgin executions do not run independant - maven

I use the latest swagger-maven-plugin from the io.swagger.core.v3 to generate my static swagger api documentation.
In my project, I have to separate apis so I want to get a json and yml representation for each api within one package process.
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>2.2.6</version>
<configuration>
<outputPath>${basedir}/target/</outputPath>
<outputFormat>JSONANDYAML</outputFormat>
<prettyPrint>true</prettyPrint>
</configuration>
<executions>
<execution>
<id>1</id>
<goals>
<goal>resolve</goal>
</goals>
<configuration>
<resourcePackages>
<resourcePackage>de.test.rest</resourcePackage>
</resourcePackages>
<outputFileName>swagger</outputFileName>
<configurationFilePath>${basedir}/src/main/resources/openApiConfig.yml</configurationFilePath>
</configuration>
</execution>
<execution>
<id>2</id>
<goals>
<goal>resolve</goal>
</goals>
<configuration>
<resourcePackages>
<resourcePackage>de.test.secondAPI</resourcePackage>
</resourcePackages>
<outputFileName>secondAPI</outputFileName>
<configurationFilePath>${basedir}/src/main/resources/secondOpenApiConfig.yml</configurationFilePath>
</configuration>
</execution>
</executions>
</plugin>
PROBLEM:
the execution creates the expected json and yml files for each execution
swagger.yml
swagger.json
secondAPI.yml
secondAPI.json
The problem is, that the seconAPI files are a copy of the swagger files.
I've read the documentation and I thought that configuration in the plugin root is shared between multiple executions. Configurations within the execution tag are individually used per execution.
Is there a way to run the executions in parallel with individual configuration?
Or is it a problem with the plugin itself?
EDIT:
Each execution works as expected when there is only one execution defined in the executions tag.

Related

jmeter-maven-plugin libraries management

I have such plugin configuration in my pom.xml
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>${jmeter.maven.plugin.version}</version>
<configuration>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-json:2.4</artifact>
<artifact>kg.apc:jmeter-plugins-casutg:2.1</artifact>
</jmeterExtensions>
<junitLibraries>
<artifact>com.microsoft.sqlserver:sqljdbc4:4.0</artifact>
</junitLibraries>
<testFilesIncluded>
<jMeterTestFile>${tests.include}</jMeterTestFile>
</testFilesIncluded>
<jMeterProcessJVMSettings>
<xms>2048</xms>
<xmx>2048</xmx>
</jMeterProcessJVMSettings>
<customPropertiesFiles>
<!-- Custom property file -->
</customPropertiesFiles>
<propertiesJMeter>
<!-- Some properties that I pass into jmeter -->
</propertiesJMeter>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
After I run mvn clean verify I get such libsat /target/jmeter/lib/:
json-path-2.1.0.jar
json-path-2.2.0.jar
and in log file I see that jmeter fails from time to time with such exception:
jmeter.extractor.json.jsonpath.JSONPostProcessor: Error processing JSON content in Select Team Name, message:Could not compile inline filter : [?(#.id=="29011")]
Note that this [?(#.id=="29011")] is only a part of expression. Full expression is looks like similar to this: $.teamData[?(#.id=="29011")].name
I expect that this error somehow related to this multiple libs
Use last version of the plugin which has solved this issue as described in release notes:
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/master/CHANGELOG.md

selecting test file (jmx file) not working with jmeter-maven-plugin

I want to select only one JMeter test file (jmx file) to run at one time. I have the following in my pom.xml:
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<testFilesIncluded>
<jMeterTestFile>ionix-${foo.bar}.jmx</jMeterTestFile>
</testFilesIncluded>
<overrideRootLogLevel>DEBUG</overrideRootLogLevel>
<testResultsTimestamp>false</testResultsTimestamp>
</configuration>
</execution>
</executions>
</plugin>
I have multiple jmx files in src/test/jmeter. It turns out those jmx files are always run by the jmeter plugin no matter what, even if I run maven with command like below:
mvn clean -Dfoo.bar=nonsense jmeter:jmeter
According to the documentation, my settings above should only execute ionix-${foo.bar}.jmx. (Whether the file ionix-${foo.bar}.jmx exists doesn't seem to make a difference in my case.) So, what am I missing here?
Thank you very much.
Enable debug in Maven by adding -X to see what is happening .
could you list content of folder that contains jmx files

jaxb2-maven-plugin with external XSD dependencies

We have a common set of XSDs (datatypes, vocabulary, etc.) we're generating with the jaxb2-maven-plugin in its own Maven project. In a second project, I need to refer to one or more of those XSDs at compile time but don't want them included in the resulting artifact. I've created a catalog file, which works fine except I get everything in it.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<target>2.1</target>
<catalog>catalog.cat</catalog>
</configuration>
I've pored over the plugin docs, but they're woefully light on detail. Is there any way to get reuse out of common schemas without every project having to take a copy of them?
Thanks
This is something my maven-jaxb2-plugin can do:
Compiling schema from Maven Artifact
The documentation site is currently very unstable so here's snippets of the documentation.
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemas>
<schema>
<dependencyResource>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin-tests-po</artifactId>
<!-- Can be defined in project dependencies or dependency management -->
<version>${project.version}</version>
<resource>purchaseorder.xsd</resource>
</dependencyResource>
</schema>
</schemas>
</configuration>
Here's a sample project.

Configuring Javadoc aggregation in Maven

I'm trying to create an aggregate Javadoc site for all the modules in my project, but I can't seem to configure the plugin in a way that is satisfactory. Mainly, I can't seem to get it to aggregate the javadocs all the while detecting links and excluding certain packages. Essentially, it appears the configuration of the plugin is ignored entirely.
I have a root pom.xml that refers to a bunch of submodules and contains the following configuration:
<modules>
<module>foo</module>
<module>bar</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.maven.apache.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>aggregate</id>
<phase>site</phase>
<goals>
<goal>aggregate</goal>
</goals>
<configuration>
<links>
<link>http://docs.oracle.com/javase/6/docs/api</link>
<link>http://static.netty.io/3.5/api</link>
<link>http://google-guice.googlecode.com/git/javadoc</link>
<link>http://docs.guava-libraries.googlecode.com/git-history/release/javadoc</link>
<link>http://fasterxml.github.com/jackson-databind/javadoc/2.0.4</link>
<link>https://developers.google.com/protocol-buffers/docs/reference/java</link>
</links>
<bootclasspath>${sun.boot.class.path}</bootclasspath>
<additionalJOption>-J-Xmx1024m</additionalJOption>
<detectJavaApiLink>true</detectJavaApiLink>
<detectLinks>true</detectLinks>
<excludePackageNames>*.testing.*</excludePackageNames>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
But when I run mvn javadoc:aggregate with this setup, I end up with a javadoc site that has no links to any of the referenced libraries and still includes all the testing classes.
I don't even see the plugin attempting to download the package-list for each declared link source.
On the other hand, generating the javadoc for each individual module works well and as expected.
What am I getting wrong?
Plugin configurations can be placed on two levels; inside the execution tag or outside of it ("global").
When the configuration is inside the execution tag it belongs to that particular execution. In your case you will have to run mvn site for it to execute since it is bound to that phase.
When the mvn javadoc:aggregate command is used it looks for the "global" configuration. In your pom there is no such configuration and thus it uses the default configuration.
Change your plugin configuration to this instead:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<links>
<link>http://docs.oracle.com/javase/7/docs/api</link>
<link>http://static.netty.io/3.5/api</link>
<link>http://google-guice.googlecode.com/git/javadoc</link>
<link>http://docs.guava-libraries.googlecode.com/git-history/release/javadoc</link>
<link>http://fasterxml.github.com/jackson-databind/javadoc/2.0.4</link>
<link>https://developers.google.com/protocol-buffers/docs/reference/java</link>
</links>
<bootclasspath>${sun.boot.class.path}</bootclasspath>
<additionalJOption>-J-Xmx1024m</additionalJOption>
<detectJavaApiLink>true</detectJavaApiLink>
<detectLinks>true</detectLinks>
<excludePackageNames>*.testing.*</excludePackageNames>
</configuration>
<executions>
<execution>
<id>aggregate</id>
<phase>site</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
You can place a configuration inside the execution part to override and specialize the configuration for that execution.
BTW The <groupId> is wrong in your pom. It should be
<groupId>org.apache.maven.plugins</groupId>
and not
<groupId>org.maven.apache.plugins</groupId>

get maven to replace values based on user/build.properties

im at the point in my project where im moving data connections to the beta and production databases for testing. obviously, having the alpha database credentials stored in the source repository is fine, but the beta and production credentials, id be put in front of a firing squad for that one.
i know maven can have a {userdir}/build.properties file. this is the file i want to use to keep the db credentials out of the source repository. but i can't seem to get maven to figure out that for file x.cfg.xml it has to replace values.
so i have in one of my hibernate.cfg.xml files this line
<property name="hibernate.connection.url">#ssoBetaUrl#</property>
now how do i get maven to replace that variable with the value thats in the {userdir}/build.properties file?
edit-------------
ive been playing with the properties-maven-plugin plugin but i seem to not be able to get it to fire. i put this in my parent pom
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<id>read-properties</id>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
</execution>
</executions>
</plugin>
but when it builds, it does not fire. if im reading http://maven.apache.org/maven-1.x/reference/properties.html right it should find the build properties file in the ~/build.properties folder and go from there, but im not sure.
I think you are approaching this the wrong way around. Instead of having the build process bake the appropriate connection details into the JAR file you should instead have the program look for a configuration file at startup.
Typically, my hibernate based apps, will look for a file under %user.home&/.appname/config.properties and load DB credentials and other deployment specfic data from there. If the file is missing, a default version can be included in the JAR and copied to this location (on initial startup so you don't have to copy-paste the file to new systems) that is then edited with appropriate settings.
This way, you can use the same build to produce JAR (or WAR) files for test and production servers, the differences will be in the (presumably already deployed) configuration files. This also makes it possible to have multiple production deployments, each talking to a different database, without any complications in the build process.
You could use two plugins.
properties-maven-plugin
replacer
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>{userdir}/build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>target/**/*.*</include>
</includes>
<replacements>
<replacement>
<token>#ssoBetaUrl#</token>
<value>http://[anyURL]</value>
</replacement>
</replacements>
</configuration>
</plugin>

Resources