I am trying to dynamically set the tags and the report locations so that I only need one testRunner. Note both are written in groovy, and I can only use up to JUnit 4.8 due to project constraints.
Thank you for any help in advance :)
//CucumberTestRunner
package cucumber
import io.cucumber.junit.Cucumber
import io.cucumber.junit.CucumberOptions
import org.junit.runner.RunWith
#RunWith(Cucumber.class)
#CucumberOptions(
features = "src/main/groovy/customFramework/dummyTests/cucumberTests/addDeal/",
glue = "src/main/groovy/customFramework/testsPackage/cucumber/StepDefinitions/",
publish = false,
monochrome = true,
tags = "${CucumberTestMaster.tag}",
plugin = ["pretty", "junit:target/JUNITReports/report.xml", "html:target/HTMLReports/report.html",
"json:target/JSONReports/report.json"]
)
class CucumberTestRunner {
}
//CucumberTestMasster
package cucumber
class CucumberTestMaster {
String tag="#Daily"
static void main(String[] args) {
new CucumberTestRunner()
}
}
Unfortunately what you're trying to do is not possible with JUnit 4. You can however use Cucumbers main method. The example below use the maven-antrun-plugin, but any other way to run a main method works.
Note that the main method is a CLI application, so if you pass --help as an argument it will explain what it's options are.
https://github.com/cucumber/cucumber-jvm/blob/main/examples/calculator-java-cli/pom.xml#L53
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>cli-test</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target unless="maven.test.skip">
<echo message="Running Cucumber through the CLI" />
<java classname="io.cucumber.core.cli.Main" fork="true" failonerror="true" newenvironment="true" maxmemory="512m" classpathref="maven.test.classpath">
<arg value="--plugin" />
<arg value="pretty" />
<arg value="--plugin" />
<arg value="html:target/results.html" />
<arg value="--plugin" />
<arg value="message:target/results.ndjson" />
</java>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
You can remove the tags from your cucumber runner file and instead pass the tag from the command line mvn clean test -Dcucumber.filter.tags=#myTest.
You can find the examples here:
https://cucumber.io/docs/cucumber/api/?lang=java#running-a-subset-of-scenarios
Related
I am using Netbeans IDE 8.0 and writing java code with the option classic Applet Project. Here all goes well till using the below import
package wallet;
import javacard.framework.*;
import javacard.framework.ISO7816;
import javacard.framework.Applet;
import javacard.framework.OwnerPIN;
but I wanted to use the global platform function so I download the JAR ( gpapi-globalplatform.jar) file from HERE and add like below,
adding new imports like below
import org.globalplatform.GPSystem;
import org.globalplatform.SecureChannel;
no error shown in IDE but during the building of code, getting the error below. Any advice here would be great.
error: export file globalplatform.exp of package org.globalplatform not found. [ INFO: ] Converter [v3.0.2]
Your found file is fine. There is a file globalplatform.exp contained in the file. You have to add the path to this file to the class path when using the Java Card converter.
Here is a configuration for Maven:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<tasks>
<echo message="Converting to CAP file"/>
<java classname="com.sun.javacard.converter.Converter"
failonerror="true" fork="true">
<arg value="-verbose"/>
<arg value="-classdir"/>
<arg value="target/classes/"/>
<arg value="-applet"/>
<arg value="${javacard.applet.aid}"/>
<arg value="${javacard.applet.name}"/>
<arg value="${javacard.package.name}"/>
<arg value="${javacard.package.aid}"/>
<arg value="${javacard.major.version}.${javacard.minor.version}"/>
<arg value="-nowarn"/>
<classpath>
<pathelement location="${jc.home}/api_export_files"/>
<pathelement location="${jc.home}/lib/apduio.jar"/>
<pathelement location="${jc.home}/lib/apdutool.jar"/>
<pathelement location="${jc.home}/lib/jcwde.jar"/>
<pathelement location="${jc.home}/lib/converter.jar"/>
<pathelement location="${jc.home}/lib/scriptgen.jar"/>
<pathelement location="${jc.home}/lib/offcardverifier.jar"/>
<pathelement location="${jc.home}/lib/capdump.jar"/>
<pathelement location="${project.basedir}/gp/export_files"/>
</classpath>
</java>
<copy todir="target/">
<flattenmapper/>
<fileset dir="target/classes/">
<include name="**/*.cap"/>
</fileset>
</copy>
</tasks>
</configuration>
</plugin>
Set the placeholders and properties as necessary.
There might be a newer version on the GlobalPlatform Specification Page. Under the section "GlobalPlatform Card API" you should find a zip file with the latest export definitions. But this should not matter.
This question is a result of an answer to this question from yesterday
run a java application and a web application in a single maven build within a reactor project
So as answered in the above question I now have a maven-antrun-plugin that forks a child process and runs my java appserver using a configuration like this -
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase> verify </phase>
<configuration>
<target>
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<exec executable="java" spawn="true">
<arg value="-classpath"/>
<arg value="${runtime_classpath}"/>
<arg value="somepackage.AppServer"/>
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The above configuration smoothly starts my appserver as a background process.
Now my question is if there is an easy way I can locate this process and stop it if I need after I start it through my build.
You can use the jps utility that is bundled inside the JDK to get the process ID of a running Java executable:
The jps tool lists the instrumented HotSpot Java Virtual Machines (JVMs) on the target system. The tool is limited to reporting information on JVMs for which it has the access permissions.
Then, when we have retrieved the process ID, we can kill it using taskkill on Windows or kill or Unix system.
This would be a sample configuration of the maven-antrun-plugin. It declares the jps executable and redirect the result of its invocation in the property process.pid with the <redirector> attribute. The result is filtered with <outputfilterchain> so that only the lines corresponding to the executable AppServer are kept. jps output is in the form [PID] [NAME] so the name is then removed with <replacestring>; this way, we only keep the PID. Finally, there are two exec configuration depending on the OS.
<configuration>
<target>
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<exec executable="java" spawn="true">
<arg value="-classpath" />
<arg value="${runtime_classpath}" />
<arg value="somepackage.AppServer" />
</exec>
<exec executable="${JAVA_HOME}/bin/jps">
<arg value="-l" />
<redirector outputproperty="process.pid">
<outputfilterchain>
<linecontains>
<contains value="somepackage.AppServer" />
</linecontains>
<replacestring from=" somepackage.AppServer" />
</outputfilterchain>
</redirector>
</exec>
<exec executable="taskkill" osfamily="winnt">
<arg value="/PID" />
<arg value="${process.pid}" />
</exec>
<exec executable="kill" osfamily="unix">
<arg value="-15" />
<arg value="${process.pid}" />
</exec>
</target>
</configuration>
Since you mentioned "gracefully", I used the -15 option on Unix and didn't include the /F option for Windows. If you want to force the exit, you can use kill -9 on the Unix system and add the /F option on Windows.
Having tried various options, I've found that the process-exec-maven-plugin to be best. I realize that the OP is asking about maven-antrun-plugin specifically but that is because of an answer received to a generic question.
https://github.com/bazaarvoice/maven-process-plugin
An example of using it to start a nodeJs server which is used as part of integration tests:
<plugin>
<groupId>com.bazaarvoice.maven.plugins</groupId>
<artifactId>process-exec-maven-plugin</artifactId>
<version>${process-exec-maven-plugin.version}</version>
<executions>
<!-- Start process -->
<execution>
<id>node-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<name>node-server</name>
<workingDir>../../test-server-dir</workingDir>
<waitForInterrupt>false</waitForInterrupt>
<healthcheckUrl>http://localhost:3000/</healthcheckUrl>
<arguments>
<argument>node</argument>
<argument>./app.js</argument>
</arguments>
</configuration>
</execution>
<!--Stop all processes in reverse order-->
<execution>
<id>stop-all</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-all</goal>
</goals>
</execution>
</executions>
</plugin>
I'm trying to build up some documentation for my Wicket Web Application. I have created a page to grab all of my mounted pages and display them in /sitemap.xml.
In the vein of documentation I've added a new tag to the file <siteMap:Description>
now I want to fill that description with the javadoc entry that describes the class file.
I know there is know direct way to access them at runtime. So Instead I'm hoping to copy them at compile time into a List where they will then be accessible from runtime. How would I do that?
I'm using Maven for my build.
EDIT
I should probably Also mention that I do have an AntTask Already defined as part of my build process to save the compile Dates/times to a property file.
It seems to me an Task to scan my Class and then put the information into a file is probably the way to go. Problem is I'm not sure how to proceed.
My Ant-Task is defined like in my pom.xml so:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>set-build-time</id>
<phase>process-sources</phase>
<configuration>
<tasks>
<tstamp>
<format property="build.timestamp" pattern="yyyy/MM/dd HH:mm:ss"/>
<format property="build.time" pattern="HH:mm:ss" />
<format property="build.date" pattern="MM/dd/yyyy" />
<format property="build.year" pattern="yyyy"/>
</tstamp>
<replaceregexp byline="true">
<regexp pattern="copyYear\=.*" />
<!--suppress MavenModelInspection -->
<substitution expression="copyYear=${build.year}" />
<fileset dir="src/main/java/" includes="**/*.properties" />
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="buildTime\=.*" />
<!--suppress MavenModelInspection -->
<substitution expression="buildTime=${build.date} ${build.time}" />
<fileset dir="src/main/java/" includes="**/*.properties" />
</replaceregexp>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
After doing more research I determined I was barking up the wrong tree.
I since I was trying to get Javadoc comments A Doclet was the better answer.
So I implemented a custom doclet and wired it up to run automatically as described in
the follow up question and answer below.
How can I compile and run my Custom Doclet class in my project?
I'm trying to implement a Maven build process for YAJSW (Yet Another Java Service Wrapper). The part I'm currently working on is generating a custom manifest for the jar to ape the format used in the currently hard-coded MANIFEST.MF file, like so:
Manifest-Version: 1.0
Class-Path-Wrapper-Core:
./wrapperApp.jar
./lib/core/yajsw/ahessian.jar
.
.
.
./lib/core/regex/jrexx-1.1.1.jar
Class-Path-Wrapper-Extended:
./lib/extended/commons/commons-httpclient-3.0.1.jar
./lib/extended/commons/commons-codec-1.3.jar
.
.
./lib/extended/abeille/formsrt.jar
Class-Path-App:
./wrapper.jar
.
.
./lib/core/commons/commons-logging-1.1.jar
Main-Class: org.rzo.yajsw.boot.WrapperExeBooter
I've managed to produce suitably formatted classpaths using the dependency:build-dep task like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>build-classpath</id>
<phase>generate-sources</phase>
<goals>
<goal>build-classpath</goal>
</goals>
<configuration>
<attach>true</attach>
<localRepoProperty>.</localRepoProperty>
<pathSeparator>$${pathDelim}</pathSeparator>
<outputFile>${basedir}/target/assembly/classPath</outputFile>
</configuration>
</execution>
</executions>
</plugin>
N.B. the $${pathDelim} part was arrived at after much experimentation with escaping, antrun and properties. Initially I tried to add newlines directly using the pathSeparator parameter. I found that the only way I could do this was to use $${line.separator}. Seems there's an extra layer of de-escaping that happens somewhere in the pipeline.
This code successfully generates a classPath file in the required format. Now I had to merge this into a MANIFEST.MF file.
On reviewing all the options, I've done this using an Antrun task :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<property name="cp.props"
value="${basedir}/target/assembly/classPath.properties" />
<concat destfile="${cp.props}">
<string>wrapper.core.classpath=</string>
<filelist dir="${basedir}/target/assembly" files="classPath" />
</concat>
<property file="${cp.props}" />
<echo file="${MANIFEST}"
message="Manifest-Version: 1.0${line.separator}Class-Path-Wrapper-Core: ${line.separator}
${wrapper.core.classpath}${line.separator}
${line.separator}
Class-Path-Wrapper-Extended: ${line.separator}
${wrapper.core.classpath}${line.separator}
${line.separator}
Class-Path-App: ${line.separator}
${wrapper.core.classpath}${line.separator}
${line.separator}
Main-Class: org.rzo.yajsw.boot.WrapperExeBooter${line.separator}" />
<replace file="${MANIFEST}" token="${pathDelim}" value=" " />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
This produced more or less the correct output in the MANIFEST.MF file:
Manifest-Version: 1.0
Class-Path-Wrapper-Core:
./commons-daemon/commons-daemon/1.0.10/commons-daemon-1.0.10.jar ./commons-configuration/commons-configuration/1.7-SNAPSHOT/commons-configuration-1.7-SNAPSHOT.jar ...
Class-Path-Wrapper-Extended:
./commons-daemon/commons-daemon/1.0.10/commons-daemon-1.0.10.jar ./commons-configuration/commons-configuration/1.7-SNAPSHOT/commons-configuration-1.7-SNAPSHOT.jar ...
Class-Path-App:
./commons-daemon/commons-daemon/1.0.10/commons-daemon-1.0.10.jar ./commons-configuration/commons-configuration/1.7-SNAPSHOT/commons-configuration-1.7-SNAPSHOT.jar ...
Main-Class: org.rzo.yajsw.boot.WrapperExeBooter
which I then pointed to in the jar plugin settings:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3</version>
<configuration>
<useDefaultManifestFile>false</useDefaultManifestFile>
<archive> <manifestFile>${MANIFEST}</manifestFile> </archive>
</configuration>
</plugin>
However, looking in the resultant jar, it seems to have flattened the output, like so:
Manifest-Version: 1.0 Class-Path-Wrapper-Core: ./commons-daemon/commons-daemon/1.0.10/commons-daemon-1.0.10.jar ./commons-configuration/commons-configuration/1.7-SNAPSHOT/commons-configuration-1.7-SNAPSHOT.jar ./commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar ./commons-lang/commons-lang/2.6/commons-lang-2.6.jar ./commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar ./commons-digester/commons-digester/1.8.1/commons-digester-1.8.1.jar ./commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar ./org/apache/commons/commons-cli/2.0-SNAPSHOT/commons-cli-2.0-SNAPSHOT.jar ./commons-io/commons-io/1.3.1/commons-io-1.3.1.jar ./org/apache/commons/commons-vfs/2.0-SNAPSHOT/commons-vfs-2.0-SNAPSHOT.jar ./commons-httpclient/commons-httpclient/3.0/commons-httpclient-3.0.jar ./commons-codec/commons-codec/1.2/commons-codec-1.2.jar ./org/apache/commons/commons-vfs2/2.0/commons-vfs2-2.0.jar ./org/apache/maven/scm/maven-scm-api/1.4/maven-scm-api-1.4.jar ./org/apache/maven/scm/maven-scm-provider-svnexe/1.4/maven-scm-provider-svnexe-1.4.jar ./org/apache/maven/scm/maven-scm-provider-svn-commons/1.4/maven-scm-provider-svn-commons-1.4.jar ./regexp/regexp/1.3/regexp-1.3.jar ./org/codehaus/groovy/groovy-all/1.8.6/groovy-all-1.8.6.jar ./net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar ./net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar ./io/netty/netty/3.3.1.Final/netty-3.3.1.Final.jar ./jrexx/jrexx/1.1.1/jrexx-1.1.1.jar ./org/rzo/ahessian/yajsw.11.0/ahessian-yajsw.11.0.jar ./org/quartz-scheduler/quartz/1.8.0/quartz-1.8.0.jar ./javax/transaction/jta/1.1/jta-1.1.jar ./org/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar ./org/slf4j/slf4j-log4j12/1.5.10/slf4j-log4j12-1.5.10.jar ./log4j/log4j/1.2.14/log4j-1.2.14.jar ./org/apache/velocity/velocity/1.6.3/velocity-1.6.3.jar ./oro/oro/2.0.8/oro-2.0.8.jar ./com/caucho/hessian/4.0.7/hessian-4.0.7.jar ./com/jgoodies/forms/1.2.0/forms-1.2.0.jar ./net/java/dev/glazedlists/glazedlists_java15/1.8.0/glazedlists_java15-1.8.0.jar ./com/jeta/abeille/forms/1.0/forms-1.0.jar ./org/codehaus/mojo/properties-maven-plugin/1.0-alpha-1/properties-maven-plugin-1.0-alpha-1.jar ./org/apache/maven/maven-model/2.0.4/maven-model-2.0.4.jar ./org/apache/maven/maven-plugin-api/2.0/maven-plugin-api-2.0.jar ./org/apache/maven/maven-project/2.0.4/maven-project-2.0.4.jar ./org/apache/maven/maven-settings/2.0.4/maven-settings-2.0.4.jar ./org/apache/maven/maven-profile/2.0.4/maven-profile-2.0.4.jar ./org/apache/maven/maven-artifact-manager/2.0.4/maven-artifact-manager-2.0.4.jar ./org/apache/maven/maven-repository-metadata/2.0.4/maven-repository-metadata-2.0.4.jar ./org/apache/maven/wagon/wagon-provider-api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar ./org/apache/maven/maven-artifact/2.0.4/maven-artifact-2.0.4.jar ./org/codehaus/plexus/plexus-container-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9.jar ./junit/junit/3.8.1/junit-3.8.1.jar ./classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar ./org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar Class-Path-Wrapper-Extended: ./commons-daemon/commons-daemon/1.0.10/commons-daemon-1.0.10.jar ./commons-configuration/commons-configuration/1.7-SNAPSHOT/commons-configuration-1.7-SNAPSHOT.jar ./commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar ./commons-lang/commons-lang/2.6/commons-lang-2.6.jar ./commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar ./commons-digester/commons-digester/1.8.1/commons-digester-1.8.1.jar ./commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar ./org/apache/commons/commons-cli/2.0-SNAPSHOT/commons-cli-2.0-SNAPSHOT.jar ./commons-io/commons-io/1.3.1/commons-io-1.3.1.jar ./org/apache/commons/commons-vfs/2.0-SNAPSHOT/commons-vfs-2.0-SNAPSHOT.jar ./commons-httpclient/commons-httpclient/3.0/commons-httpclient-3.0.jar ./commons-codec/commons-codec/1.2/commons-codec-1.2.jar ./org/apache/commons/commons-vfs2/2.0/commons-vfs2-2.0.jar ./org/apache/maven/scm/maven-scm-api/1.4/maven-scm-api-1.4.jar ./org/apache/maven/scm/maven-scm-provider-svnexe/1.4/maven-scm-provider-svnexe-1.4.jar ./org/apache/maven/scm/maven-scm-provider-svn-commons/1.4/maven-scm-provider-svn-commons-1.4.jar ./regexp/regexp/1.3/regexp-1.3.jar ./org/codehaus/groovy/groovy-all/1.8.6/groovy-all-1.8.6.jar ./net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar ./net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar ./io/netty/netty/3.3.1.Final/netty-3.3.1.Final.jar ./jrexx/jrexx/1.1.1/jrexx-1.1.1.jar ./org/rzo/ahessian/yajsw.11.0/ahessian-yajsw.11.0.jar ./org/quartz-scheduler/quartz/1.8.0/quartz-1.8.0.jar ./javax/transaction/jta/1.1/jta-1.1.jar ./org/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar ./org/slf4j/slf4j-log4j12/1.5.10/slf4j-log4j12-1.5.10.jar ./log4j/log4j/1.2.14/log4j-1.2.14.jar ./org/apache/velocity/velocity/1.6.3/velocity-1.6.3.jar ./oro/oro/2.0.8/oro-2.0.8.jar ./com/caucho/hessian/4.0.7/hessian-4.0.7.jar ./com/jgoodies/forms/1.2.0/forms-1.2.0.jar ./net/java/dev/glazedlists/glazedlists_java15/1.8.0/glazedlists_java15-1.8.0.jar ./com/jeta/abeille/forms/1.0/forms-1.0.jar ./org/codehaus/mojo/properties-maven-plugin/1.0-alpha-1/properties-maven-plugin-1.0-alpha-1.jar ./org/apache/maven/maven-model/2.0.4/maven-model-2.0.4.jar ./org/apache/maven/maven-plugin-api/2.0/maven-plugin-api-2.0.jar ./org/apache/maven/maven-project/2.0.4/maven-project-2.0.4.jar ./org/apache/maven/maven-settings/2.0.4/maven-settings-2.0.4.jar ./org/apache/maven/maven-profile/2.0.4/maven-profile-2.0.4.jar ./org/apache/maven/maven-artifact-manager/2.0.4/maven-artifact-manager-2.0.4.jar ./org/apache/maven/maven-repository-metadata/2.0.4/maven-repository-metadata-2.0.4.jar ./org/apache/maven/wagon/wagon-provider-api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar ./org/apache/maven/maven-artifact/2.0.4/maven-artifact-2.0.4.jar ./org/codehaus/plexus/plexus-container-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9.jar ./junit/junit/3.8.1/junit-3.8.1.jar ./classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar ./org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar Class-Path-App: ./commons-daemon/commons-daemon/1.0.10/commons-daemon-1.0.10.jar ./commons-configuration/commons-configuration/1.7-SNAPSHOT/commons-configuration-1.7-SNAPSHOT.jar ./commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar ./commons-lang/commons-lang/2.6/commons-lang-2.6.jar ./commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar ./commons-digester/commons-digester/1.8.1/commons-digester-1.8.1.jar ./commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar ./org/apache/commons/commons-cli/2.0-SNAPSHOT/commons-cli-2.0-SNAPSHOT.jar ./commons-io/commons-io/1.3.1/commons-io-1.3.1.jar ./org/apache/commons/commons-vfs/2.0-SNAPSHOT/commons-vfs-2.0-SNAPSHOT.jar ./commons-httpclient/commons-httpclient/3.0/commons-httpclient-3.0.jar ./commons-codec/commons-codec/1.2/commons-codec-1.2.jar ./org/apache/commons/commons-vfs2/2.0/commons-vfs2-2.0.jar ./org/apache/maven/scm/maven-scm-api/1.4/maven-scm-api-1.4.jar ./org/apache/maven/scm/maven-scm-provider-svnexe/1.4/maven-scm-provider-svnexe-1.4.jar ./org/apache/maven/scm/maven-scm-provider-svn-commons/1.4/maven-scm-provider-svn-commons-1.4.jar ./regexp/regexp/1.3/regexp-1.3.jar ./org/codehaus/groovy/groovy-all/1.8.6/groovy-all-1.8.6.jar ./net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar ./net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar ./io/netty/netty/3.3.1.Final/netty-3.3.1.Final.jar ./jrexx/jrexx/1.1.1/jrexx-1.1.1.jar ./org/rzo/ahessian/yajsw.11.0/ahessian-yajsw.11.0.jar ./org/quartz-scheduler/quartz/1.8.0/quartz-1.8.0.jar ./javax/transaction/jta/1.1/jta-1.1.jar ./org/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar ./org/slf4j/slf4j-log4j12/1.5.10/slf4j-log4j12-1.5.10.jar ./log4j/log4j/1.2.14/log4j-1.2.14.jar ./org/apache/velocity/velocity/1.6.3/velocity-1.6.3.jar ./oro/oro/2.0.8/oro-2.0.8.jar ./com/caucho/hessian/4.0.7/hessian-4.0.7.jar ./com/jgoodies/forms/1.2.0/forms-1.2.0.jar ./net/java/dev/glazedlists/glazedlists_java15/1.8.0/glazedlists_java15-1.8.0.jar ./com/jeta/abeille/forms/1.0/forms-1.0.jar ./org/codehaus/mojo/properties-maven-plugin/1.0-alpha-1/properties-maven-plugin-1.0-alpha-1.jar ./org/apache/maven/maven-model/2.0.4/maven-model-2.0.4.jar ./org/apache/maven/maven-plugin-api/2.0/maven-plugin-api-2.0.jar ./org/apache/maven/maven-project/2.0.4/maven-project-2.0.4.jar ./org/apache/maven/maven-settings/2.0.4/maven-settings-2.0.4.jar ./org/apache/maven/maven-profile/2.0.4/maven-profile-2.0.4.jar ./org/apache/maven/maven-artifact-manager/2.0.4/maven-artifact-manager-2.0.4.jar ./org/apache/maven/maven-repository-metadata/2.0.4/maven-repository-metadata-2.0.4.jar ./org/apache/maven/wagon/wagon-provider-api/1.0-alpha-6/wagon-provider-api-1.0-alpha-6.jar ./org/apache/maven/maven-artifact/2.0.4/maven-artifact-2.0.4.jar ./org/codehaus/plexus/plexus-container-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9.jar ./junit/junit/3.8.1/junit-3.8.1.jar ./classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar ./org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar Main-Class: org.rzo.yajsw.boot.WrapperExeBooter
Archiver-Version: Plexus Archiver
Created-By: 20.0-b11 (Sun Microsystems Inc.)
Any idea how to fix this?
P.S.On further inspection, it appears this flattening is mostly a natural consequence of the jar-building process, and happened in the original Gradle build too. However, I still have all the classpaths on one line, and need to keep them separate... I wonder if this is as a result of the merging of multiple discrete manifests by Gradle?
Looks like the indentation in the POM file was causing spaces to appear in the generated MANIFEST.MF file, and those spaces were being interpreted as indication of line continuation.
I've rejigged the antrun section as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<property name="cp.props"
value="${basedir}/target/assembly/classPath.properties" />
<property name="ls" value="${line.separator}"/>
<concat destfile="${cp.props}">
<string>wrapper.core.classpath=</string>
<filelist dir="${basedir}/target/assembly" files="classPath" />
</concat>
<property file="${cp.props}" />
<echo file="${MANIFEST}"
message="Manifest-Version: 1.0
${ls}Class-Path-Wrapper-Core: ${ls} ${wrapper.core.classpath}${ls}
${ls}Class-Path-Wrapper-Extended: ${ls} ${wrapper.core.classpath}${ls}
${ls}Class-Path-App: ${ls} ${wrapper.core.classpath}${ls}
${ls}Main-Class: org.rzo.yajsw.boot.WrapperExeBooter${ls}" />
<replace file="${MANIFEST}" token="${pathDelim}" value=" " />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
YAJSW seems a bit happier now when referencing the classpaths in the .jar, although I haven't got it quite right yet. Still, pretty happy with this outcome! Hope all my findings are of use to someone - I couldn't find this info on SO or in the Maven docs.
I want to share test resources between 2 modules A and B. In A test resources I have directory with some files. Like this
-dir
----f1
----f2
I've done all according to Share test resources between maven projects . Now from B test I can access to resources using syntax like:
this.getClass().getClassLoader().getResource("dir/f1")
And it's works perfectly fine. But I don't want hardcore all file names like f1 or f2. What I really want is getting all files from directory. Like
File foo = new File(this.getClass().getClassLoader().getResource("dir").getFile());
assert foo.isDirectory()
foo.list()
...
But when I create foo in such way it even doesn't exist (foo.exist() returns false).
How can I deal with it?
Update. Alternative solution using ant
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<configuration>
<target>
<fileset id="d" dir="${basedir}/src/test/resources/dir" includes="*"/>
<pathconvert property="d" refid="d">
<map from="${basedir}/src/test/resources/" to=""/>
</pathconvert>
<touch file="${basedir}/src/test/resources/d/listOfCharts.txt"/>
<echo file="${basedir}/src/test/resources/d/listOfCharts.txt" message="${charts}"/>
</target>
</configuration>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The approach you talk about creates a JAR which can be used in later tests. You can't list the contents of a Jar this way. You need to use Jar you need to read it as a Jar specially
How do I list the files inside a JAR file?