<build>
       <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-jar-plugin</artifactId>
               <version>2.2</version>

               <executions>
                   <execution>
                       <goals>
                           <goal>test-jar</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
        </plugins>
    </build>
mvn clean install

<dependency>
    <groupId>com.foo</groupId>
    <artifactId>bar</artifactId>
    <version>1.2.3</version>
    <type>test-jar</type>
    <scope>test</scope>
 </dependency>

 

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.0.2</version>
        <configuration>
          <archive>
            <manifest>
              <mainClass>com.test</mainClass>
            </manifest>
            <manifestEntries>
              <Specification-Title>${project.name}</Specification-Title>
              <Specification-Version>${project.version}</Specification-Version>
              <Implementation-Version>${build.number}</Implementation-Version>
              <Change>${project.version}</Change>
              <Build-Date>${maven.build.timestamp}</Build-Date>
            </manifestEntries>
          </archive>
        </configuration>
       <executions>
         <execution>
           <goals>
             <goal>test-jar</goal>
           </goals>
         </execution>
       </executions>
      </plugin>