This is pretty similar to the Copying project dependencies or Unpacking project dependencies examples.
Instead of using the project dependencies it uses their sources. Use the goal copy-dependencies to just copy the sources jars to a directory or unpack-dependencies to extract them. See the sample below:
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>src-dependencies</id> <phase>package</phase> <goals> <!-- use copy-dependencies instead if you don't want to explode the sources --> <goal>unpack-dependencies</goal> </goals> <configuration> <classifier>sources</classifier> <failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact> <outputDirectory>${project.build.directory}/sources</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build> [...] </project>