Renaming resources in Maven

Using the antrun-maven-plugin makes it easy, but in case you are looking for a more mavenish way which is supported within eclipse m2e, then you can use the copy-rename-maven-plugin <plugin> <groupId>com.coderplus.maven.plugins</groupId> <artifactId>copy-rename-maven-plugin</artifactId> <version>1.0.1</version> <executions> <execution> <id>rename-file</id> <phase>compile</phase> <goals> <goal>rename</goal> </goals> <configuration> <sourceFile>${project.build.outputDirectory}/default.DS_Store</sourceFile> <destinationFile>${project.build.outputDirectory}/.DS_Store</destinationFile> </configuration> </execution> </executions> </plugin> And in case you have any feedback/issues with … Read more

m2e lifecycle-mapping not found

The org.eclipse.m2e:lifecycle-mapping plugin doesn’t exist actually. It should be used from the <build><pluginManagement> section of your pom.xml. That way, it’s not resolved by Maven but can be read by m2e. But a more practical solution to your problem would be to install the m2e build-helper connector in eclipse. You can install it from the Window … Read more

How to get Maven to run war:exploded but not war:war

The solution is quite simple. You need to override the default execution of the war plugin to disable it and add your own execution (for exploded): <pluginManagement> <plugins> <plugin><!– don’t pack the war –> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <executions> <execution> <id>default-war</id> <phase>none</phase> </execution> <execution> <id>war-exploded</id> <phase>package</phase> <goals> <goal>exploded</goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement>

Maven: Including jar not found in public repository

You can install the project yourself. Or you can use the system scope like the following: <dependency> <groupId>org.group.project</groupId> <artifactId>Project</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${basedir}/lib/project-1.0.0.jar</systemPath> </dependency> systemPath requires the absolute path of the project. To make it easier, if the jar file is within the repository/project, you can use ${basedir} property, which is bound to the root of … Read more

Maven – how can I add an arbitrary classpath entry to a jar?

I found that there is an easy solution for this problem. You can add a <Class-Path> element to <manifestEntries> element, and set <addClassPath>true</addClassPath> to <manifest> element. So value of <Class-Path> element is added to class-path automatically. Example: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addClasspath>true</addClasspath> <mainClass>your.main.Class</mainClass> </manifest> <manifestEntries> <Class-Path>../conf/</Class-Path> </manifestEntries> </archive> </configuration> </plugin>

How to display a list of available goals?

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: … Read more

Where is the best place to specify maven repositories, pom.xml or settings.xml?

Where is the best place to specify required repositories for maven projects, pom.xml or settings.xml? What are the pros and cons of each location? What is best practice? I’d personally define the repositories required by a particular project in the project pom.xml because it keeps the build portable. The settings.xml file should be used for … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)