I want to create a specific custom file structure for developping and I want to know if it could be done with maven.
It is important to mention that i am using c++ for programming language and the Maven-nar-plugin
I want to be able run a command like : mvn dependency:resolve and the required librairies would go in the folder Librairies. That way all i would have to do is link the include folder of a library to my project in Visual Studio.
I dont want to compile with maven I just want to use it's dependency manager
I know you can change the SourceDirectory but can you change where the Librairies will be installed ?
Workspace
|
|-- Project1
| |-- pom.xml
|
|-- Project2
| |-- pom.xml
|
|-- Librairies
|-- ExempleLib-V-2.0
| |-- Include
| |-- lib
|
|-- ExempleLib-V-3.1
Sure, you can tell maven that your local repository is in this Librairies directory rather than in ~/.m2/repository
You can pass parameter maven.repo.local when launching it and it will download everything there
mvn -Dmaven.repo.local=Librairies clean install
I found a way using maven-dependency-plugin.
The following code will take every dependency and copy it over to the Librairies folder.
You could even use unpack-dependencies instead of copy-dependencies to directly unpack the dependency in the folder
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
../Libraries
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Related
I have an issue concerning the target directory of aggregated javadocs.
What I have is:
A maven project containing several modules. It looks a bit like the one used as example here
Project
|-- directory_to_contain_docs/
|-- pom.xml
|-- Module1
| `-- pom.xml
|-- Module2
| `-- pom.xml
`-- Module3
`-- pom.xml
I can't get it done to make javadoc generate the documentation in the directory named "directory_to_contain_docs".
This is what I tried:
I call the generation with "mvn javadoc:aggregate". And this is a part of the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<!-- Default configuration for all reports -->
<failOnError>false</failOnError>
<destDir>${basedir}/directory_to_contain_docs</destDir>
<!-- as there are lots of incorrectly documented sources -->
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>site</phase>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The javadoc is always generated in {project}/target/site/apidocs, the generation creates the complete path given in destDir beneath that directory. I am looking for a way to have the whole docs somewhere else.
Is there a chance to achieve that?
Thanks,
Ishiido
Don't know why I did not see it... The missing link is
configuration/reportOutputDirectory.
It specifies the directory where the documentation is generated. It may be specified further by destDir.
I'm trying to use Maven Checkstyle plugin in a multi module project.
The default setting for <sourceDirectories> (where the plugin to start looking for code) is ${project.compileSourceRoots}. This resolves to [C:\workspace\projectname\src\main\java] in my case, i.e. a List<String>.
Now, that default path is of no value to me, since my code resides in different places, like so: [C:\workspaces\projectname\module1\src\main\java]. Hence, I need to change <sourceDirectories> to a list of directories where my code actually is.
So far, so good...
The problem is that <sourceDirectories> expects a List<String>. I tried the following:
<sourceDirectories>
<sourceDirectory>pathToCode1</sourceDirectory>
<sourceDirectory>pathToCode2</sourceDirectory>
</sourceDirectories>
... but that didn't work. It will take the default path. (Moreover, <sourceDirectory> is deprecated!)
Having only one <sourceDirectory> (without the surrounding <sourceDirectories>) does work, but <sourceDirectory> only takes one path and you can't have more than one <sourceDirectory>. So, no cigar. Also, keep in mind <sourceDirectory> is deprecated.
I also tried various other methods of providing a List<String> to <sourceDirectories>, but alas, no progress. Here are some examples:
<sourceDirectories>[pathToCode]</sourceDirectories>
<sourceDirectories>pathToCode</sourceDirectories>
<sourceDirectories>{pathToCode}</sourceDirectories>
<sourceDirectories>{[pathToCode]}</sourceDirectories>
<sourceDirectories>{{pathToCode}}</sourceDirectories>
<sourceDirectories>{{{pathToCode}}}</sourceDirectories>
Is there another way of (directly, without "sub-tags") providing a List<String> to maven?
Is the plugin broken?
Have I missed something?
Edits below
My project structure:
MyProject
|-- pom.xml <-- plugin runs fine here
|-- domain-module
| |-- src
| | `-- main
| | `-- com/example/hello...
| | |-- TheCode.java
| | `-- resources
| | |-- checkstyle.xml
| | `-- LICENSE.TXT
| `-- pom.xml
|-- poms
| |-- parent
| | `-- pom.xml <-- this is my parent pom
My parent pom
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.16</version>
<dependencies>
<dependency>
<groupId>com.example.hello</groupId>
<artifactId>domain-module</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>domain-module/src/main/resources/checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
<logViolationsToConsole>true</logViolationsToConsole>
<skip>false</skip>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<...>
</build>
</pluginManagement>
</plugins>
Since version 2.13 the use of sourceDirectories is broken (https://issues.apache.org/jira/browse/MCHECKSTYLE-260).
With 2.12 it works. Andreas Dangel mentioned in Jira:
The configuration described here
Checkstyle - Exclude folder
still works. Then the exclusion happens in checkstyle, rather than in
maven-checkstyle-plugin.
I'm looking for best way to structure maven projects which use JAX-WS, specifically where multiple JAX-WS projects which share common schema.
For example, if we have the following structure
ProjectA
|- pom.xml
\- src
\- wsdl
\- projectA.wsdl
ProjectB
|- pom.xml
\- src
\- wsdl
\- projectB.wsdl
Both ProjectA and ProjectB import CommonTypes.xsd. Where should we put CommonTypes.xsd and how should we configure ProjectA & ProjectB so jaxws-maven-plugin is able to process them correctly?
I would suggest to put the CommonTypes.xsd in an extra Maven project which is deployed to your maven repository. For simplicity I would create this as jar project and only inlcude the xsd file.
The your projectA and B can use the maven-dependency-plugin to unpack the xsd to a specific folder in ProjectA/B where your wsdl is expecting the xsd:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>unpack</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>groupId</groupId>
<artifactId>commont-types-xsd</artifactId>
<version>1.0</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Maybe you need to play around with the execution order because the jaxws-plugin is also running in the generate-sources cycle or maybe change the dependency plugin to an earlier phase.
An other solution would be to create the extra project and having something like a catalogue service server were you store the xsd files common over all projects and the wsdl just needs to point to this server url.
I have a maven project with a non standard configuration:
$> tree
.
├── pom.xml
├── symbolic-link-to-sources -> ../src
└── target
├── maven-archiver
│ └── pom.properties
├── project-1.0-SNAPSHOT-sources.jar
├── project-1.0-SNAPSHOT.jar
└── surefire
I am trying to generate the sources jar of this maven module, whose sources are in ../src. I created a symbolic link to ../src in the case the plugin does not accept parent folders in paths. To do so I use the maven source plugin configured like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<includePom>true</includePom>
<includes>
<include>symbolic-link-to-sources/**</include>
</includes>
</configuration>
</plugin>
I run this plugin with mvn source:jar. Unfortunately I get only pom.xml in my sources jar. If I set includePom to false the plugin does not create the source archive.
I tried a lot of things as <include>: ../src, ../src/**, ../**, symbolic-link-to-sources, symbolic-link-to-sources/**, ../**/*.java none of them get me my sources into my sources jar. Although the documentation about it say its a relative fileset pattern.
Any idea how to get the content the java files of the ../src folder into my sources jar?
(Yes my symbolic link is not broken, no there is no way to rearrange my modules to have a standard folder hierarchy, this is a wrapper project around an ant based project).
You would use the <includes property to specify files/patterns to include within the source folder.
Have you set <sourceDirectory> to the correct location of the source (symbolic link and so on)? If so, can you omit the entire plugin configuration above and just run mvn source:jar on the pom? It should generate the sources correctly.
Stuck with the same problem and after googling and trying finally came to this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../common/src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
Where "../common/src/main/java" is a path to sources that are linked as symbolic link in the current project.
Please note that build-helper-maven-plugin has package phase. With phase generate-sources I was getting "duplicate class" since the same sources were added from the symbolic link dir and from the dir configured in build-helper-maven-plugin.
I have multimodule maven project like this
myproject
framework1
f1-presentation
*.java
f1-core
*.java
f1-tag
*.java
framework2
f2-presentation
*.java
f2-core
*.java
f2-tag
*.java
I want to create apidocs for all java files. If I run mvn javadoc:aggregate in the project root it creates apidcos in the target directory of project root (target/sites/apidocs). But what I want is to create this apidocs for each 2nd level modules. As for example I want apidocs for all java files of framework1 to be create in framework1/target/sites/apidocs. Same thing goes for framework2. Final result will be like this
myproject
framework1
target/sites/apidocs (this will contain javadocs for all its submodules classes)
f1-presentation
*.java
f1-core
*.java
f1-tag
*.java
framework2
target/sites/apidocs (this will contain javadocs for all its submodules classes)
f2-presentation
*.java
f2-core
*.java
f2-tag
*.java
Could you guys tell me how to do that using maven javadoc plugin.
Edit:
pom.xml in framework1 contains
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
After digging a lot I found that maven javadoc plugin is not so good for multimodule project. Actually what I wanted in my question is not done yet. Its a bug of maven javadoc plugin. Here is the bug link
http://jira.codehaus.org/browse/MJAVADOC-311
One way to achieve this could be to run mvn javadoc:aggregate in each of framework1 and framework2 folders separately.
The other would be to configure the poms of framework1 and framework2 to aggregate as specified in this example and run mvn site from myproject.