maven-2

Jacoco code coverage show 0% coverage on Jenkins

老子叫甜甜 提交于 2019-12-04 18:43:26
I have read most of the answers available for similar questions but none of those fit to answer my question. My profile in pom file looks like this: <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.7.7.201606060606</version> <executions> <!-- Prepares the property pointing to the JaCoCo runtime agent which is passed as VM argument when Maven the Surefire plugin is executed. --> <execution> <id>pre-unit-test</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <!-- Sets the path to the file which contains the execution data. --

How do you force a maven MOJO to be executed only once at the end of a build?

自闭症网瘾萝莉.ら 提交于 2019-12-04 18:26:11
问题 I have a MOJO I would like executed once, and once only after the test phase of the last project in the reactor to run. Using: if (!getProject().isExecutionRoot()) { return ; } at the start of the execute() method means my mojo gets executed once, however at the very beginning of the build - before all other child modules. 回答1: The best solution I have found for this is: /** * The projects in the reactor. * * @parameter expression="${reactorProjects}" * @readonly */ private List

Maven dependency log4j error

混江龙づ霸主 提交于 2019-12-04 17:36:24
问题 Hello everyone I have error which breaks up my build for no reason, here is the error message : error: error reading /.m2/repository/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar; error in opening zip file error: error reading /.m2/repository/com/sun/jmx/jmxri/1.2.1/jmxri-1.2.1.jar; error in opening zip file I'm using this dependency : <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.15</version> <scope>provided</scope> </dependency> How can I fix this ? 回答1:

Maven2 inheritance

梦想的初衷 提交于 2019-12-04 17:11:26
问题 If I have a parent pom and want to inherit this to several projects. I usually do this by adding in top of the project <parent> ... </parent> . What I don't like about this approach is that if something changes in my parent I have to edit all project which are inherited by that parent to modify the version number. Is there a better approach? I hope it is understandable what I'm trying to explain. Thanks in advance. 回答1: What i don't like about this approach is that if something changes in my

Activating a profile by default

若如初见. 提交于 2019-12-04 16:56:21
问题 I'm using Maven 3.0.3. I need to define a variable in my script ("env"). I have a <profiles> section in my pom in which I define the variable per <profile> element ... <profile> <id>qa</id> <properties> <env>qa</env> ... </properties> </profile> In my pom.xml, how do I activate a profile only if none was specified via the "-P" command line option (and hence set the variable if it was not defined)? I tried the below, <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault>

Having a maven project build its own dependencies?

倖福魔咒の 提交于 2019-12-04 16:29:41
问题 With maven is it possible to have a top-level project who's packaging type is "war" which will build itself and all of its dependent modules (packaged as jar) and have the build generate a project.war file? Much of the documentation examples and other examples I've seen often use a top-level project with packaging type of "pom" and the project only serves the purpose of tying the modules together. Can I avoid this? So basically I need something which is effectively like declaring a <module>my

New at Maven: Using the shade plugin and 3rd party jars

佐手、 提交于 2019-12-04 16:29:28
This should be pretty simple, but I can't the around to it. I need to create an uberjar using 3rd party jars. I've already followed these instructions: Including a non-Mavenized dependency so it works with maven-shade-plugin and added them to the local repository. But now what? Every Maven tutorial/example is kinda shady (pun intended) and I just don't know how to edit the .pom file properly in order to make it work. Besides, I'm confused about the shade "plugin" overall. I mean, I followed the basic Maven tutorials and it went all fine and dandy. But when I look into the shade plugin page, I

Best way to access the runtime configuration of a maven plugin from a custom mojo?

。_饼干妹妹 提交于 2019-12-04 16:25:44
问题 I am writing a custom maven2 MOJO. I need to access the runtime configuration of another plugin, from this MOJO. What is the best way to do this? 回答1: You can get a list of plugins currently been used in the build using the following steps: First you need to get Maven to inject the current project into your mojo, you use the class variable defined below to get this. /** * The maven project. * * @parameter expression="${project}" * @readonly */ private MavenProject project; Then you can use

Override Maven's default resource filter replacement pattern

亡梦爱人 提交于 2019-12-04 16:19:41
问题 By default maven will filter resources like this: <properties> <replace.me>value</replace.me> </properties> <some-tag> <key>${replace.me}</key> </some-tag> will get you: <some-tag> <key>value</key> </some-tag> Is there a way to override the way maven selects the strings to replace? Specifically, I want to be able to use this: <some-tag> <key>@replace.me@</key> </some-tag> to get the same result as above. 回答1: Have a look at the delimiters parameter of the resources mojo. Configuring the

Java maven development slow

拟墨画扇 提交于 2019-12-04 16:07:09
I am developing a war/java website that is built via maven. Currently, I have to make changes... tell maven to build them... then deploy to Tomcat. This is around 40seconds . So every change I make, I have to wait >=40seconds to see the change. This is becoming very frustrating, so I have tried to speed up the deployment. I deployed the site via maven with war:exploded. Now, I edit the files live in 'deployed' format. The problem being I will need to move these changes back to the source location for pushing into our source control. So has anyone written a script to 'undeploy' changes on the