When building a Maven plugin, where can I find documentation for the built-in expressions that can be used for #parameter expression="${...}" constructs?
You might also try the help:evaluate goal of the maven help plugin to quickly show the values of one of these properties from the command line. For example
mvn help:evaluate -Dexpression=project.build.outputDirectory
would echo the output directory of the current project.
There is the Maven Properties Guide. Check also the chapter 9.2. Maven Properties of Maven: The Complete Reference.
Related
I have my JDK documentation path set so that I can hit Cntrl J (osx) to get 'quick documentation lookup' for core java libraries. If I try with non-core libraries like Spring or Hibernate, I only get the method signature. How do I go about getting the documentation for these libraries too?
Attach documentation directory or specify external documentation URL, or attach sources.
If you're using Maven, you can use the Maven goal :
mvn dependency:resolve -Dclassifier=javadoc .
This goal resolves the project dependencies from the repository. The classifier specify to look for javadocs. All documentation will be downloaded inside your maven local repository, generally ~/.m2 .
After that, IntelliJ is able to find all javadoc for Spring, Hibernate, if not, check your settings inside Project Structure.
In general, what is the best strategy for finding the groupId and artifactId for a well-known dependency for use in a Maven POM? For example, how would I find the correct entry for the MySQL JDBC driver? It's not mentioned on the mysql.com site, so I would usually spend time looking for another POM that already uses the Maven repository version of the jar. This can't be the best way.
I would suggest to use http://search.maven.org
M2Eclipse, the maven integration of eclipse, supports local searchable indexes of maven repositories. So you can right-click a project or a pom.xml and do
Maven -> Add Dependency
A dialog appears where you can search for artifacts from your local indexes. Wouldn't want to miss it.
If that's not an option, use mvnrepository.com
Most of the time my IDE does this for me. But when I'm not sure I search manually; Google really helps.
You can also search on maven search engines like this mvnrepository.com.
I use http://repository.sonatype.org.
Maven site suggests to browse biblio to get maven co-ordinates; http://www.ibiblio.org/ .
Say for log4j
First, we need to know what the groupId, artifactId, and version are for log4j. We can browse ibiblio and look for it, or use Google to help by searching for "site:www.ibiblio.org maven2 log4j".
Maven metadata for log4j: http://mirrors.ibiblio.org/maven2/log4j/log4j/maven-metadata.xml
In my experience the best option is mvnrepository.com. for example in your case, just type mysql in the search text field. you will find all available artifacts that contain mysql string. in your case the one fit your needs is: mysql-connector-java
for each artifact you have a general description that helps you decide what is best for you.
once you click it you get all the available versions and once you click on a version you have all sort of information about it like the code you need to add to your pom.xml, the artifact dependencies and so on...
1. Go to http://search.maven.org
2. Search in the required jar with groupId/artifactId or Just with basic text.
Like for your case
I'd like to generate liquibase's dbdoc as part of my maven site build, but I cannot figure out how to do this. My thoughts were to add maven-antrun-plugin to the reporting section of the pom, but I cannot have an node under plugin in the reporting section. Any ideas?
This is not supported by the Maven LiquiBase Plugin so either create your own report plugin or use the dbDoc Ant Task and the Maven AntRun Plugin to generate the documentation under target/site/.
In the later case, bind the plugin on one of the phases of the Site Lifecycle (this will require some testing but I think that pre-site, site or post-site would be ok) and add an entry in the left menu in the site descriptor.
You can create your own reports plugin, more information here:
http://docs.codehaus.org/display/MAVENUSER/Write+your+own+report+plugin
I'm rather new to Maven and I often find myself wanting to see what's actually there in terms of goals.
So, is there a command which lists all available goals for e.g. a given prefix?
Since Maven is an open system of plugins, the best answer is probably "Google" ;-). If you mean all build lifecycle phases, they are static, and can be found at http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html and at other places.
Then, for a given plugin, the help plugin can be used to get the possible goals and all their parameters:
mvn help:describe -DgroupId=org.apache.maven.plugins \
-DartifactId=maven-war-plugin \
-Ddetail=true
But this doesn't really answer your question, especially the "for a given prefix" part. For this, the best solution might be to use **auto completion with BASH (**not sure it will be exhaustive though). See for example the Guide to Maven 2.x auto completion using BASH. To get bash completion working under Windows, you'll need CYGWIN. See Maven Tab Auto Completion in Bash for detailed setup steps (and a "better" working auto completion script).
A shorter way
As an alternative, you can also use the -Dplugin parameter to display the list of available goals.
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-war-plugin\
-Ddetail=true
See Maven help plugin.
More and more Maven plugins propose an help goal as alternative to the verbose
mvn help:describe command.
You can read from the Maven doc:
Recent Maven plugins have generally an help goal to have in the
command line the description of the plugin, with their parameters and
types
That is really more natural and pleasant to use.
It works of course for Maven core plugins.
Some examples :
to list goals of the dependency plugin :
mvn dependency:help
to have detail about the javadoc goal of the javadoc plugin :
mvn javadoc:help -Ddetail -Dgoal=javadoc
And it works also for third party plugins.
For example, to list goals of the spring-boot-maven-plugin :
mvn org.springframework.boot:spring-boot:help
[INFO] Spring Boot Maven Plugin 2.0.0.RELEASE Spring Boot Maven
Plugin
This plugin has 6 goals:
spring-boot:build-info
Generate a build-info.properties file based the content of the
current MavenProject.
spring-boot:help
Display help information on spring-boot-maven-plugin. Call mvn
spring-boot:help -Ddetail=true -Dgoal= to display
parameter details.
spring-boot:repackage
Repackages existing JAR and WAR archives so that they can be
executed from the command line using java -jar. With layout=NONE can
also be used simply to package a JAR with nested dependencies (and
no main class, so not executable).
.....
Or to get detailed information about the build goal of the dockerfile-maven-plugin :
mvn com.spotify:dockerfile-maven-plugin:help -Ddetail -Dgoal=build
[INFO] Dockerfile Maven Plugin 1.3.6
Adds support for building Dockerfiles in Maven
dockerfile:build
Available parameters:
- archive
The archive configuration to use for the Docker info JAR. This can be used
to embed additional information in the JAR.
....
You could note that the syntax to get a detailed output of the help and to focus on a specific goal (-Ddetail -Dgoal=myGoal) is exactly the same as this used for the core maven plugins.
Of course some esoteric plugins may not provide the help goal but in most of well designed plugins this is present.
What are the minimum steps I should follow to replace Ant with Maven?
Set up your project according to the standard directory layout.
Create a minimal pom.xml with groupId, artifactId and version.
Add your dependencies to the pom.xml
Compare the WAR/JAR/EAR to the old version see if there is any change. Take actions to minimize the differences as told here.
You should now be able to build a simple project, run the tests and package it.
Anecdote: Once you are in Maven, the reverse trip (though why would you ever go back!) is so simple:
mvn ant:ant
generates functionally equivalent ant scripts. Now if only an Ant->Maven generator existed.
You can have a look to ant2maven script, that builds pom.xml from Ant scripts. I've never tried it, but it can be used to have a good pom.xml to start with...