我有一个大型多模块Maven构建,目前混合使用PowerMock和Mockito测试(很快将所有PowerMock测试移至Mockito)。父pom中的默认jacoco-maven-plugin配置用于"离线"仪器,但Mockito测试的一个模块是使用在线仪器。我相信模块中的每个jacoco.exec文件都是正确构建的。
其中一个名为" jacoco-aggregate"的子模块,只是尝试使用" merge"和"报告 - 聚合"目标。我正在使用" merge"因为我正在与SonarQube集成,我们使用的版本只允许一个exec文件。从输出我可以看到,"合并"目标似乎正常。
"报告 - 聚合"目标似乎有问题。它目前根本没有产生任何报道。显示的表格为空。
以下是我在jacoco子模块中构建时获得的当前输出:
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jacoco-aggregate ---
[INFO] Deleting <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (filter) @ jacoco-aggregate ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\src\main\resources
[INFO]
[INFO] --- depends-maven-plugin:1.2:generate-depends-file (generate-depends-file) @ jacoco-aggregate ---
[INFO] Created: <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\target\classes\META-INF\maven\dependencies.properties
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:report (default-report) @ jacoco-aggregate ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- maven-javadoc-plugin:2.10.4:jar (module-javadoc-jar) @ jacoco-aggregate ---
[INFO] Not executing Javadoc as the project is not a Java classpath-capable package
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:report-aggregate (report-aggregate) @ jacoco-aggregate ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:merge (merge) @ jacoco-aggregate ---
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-account-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-core-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-creditcheck-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-ordercreation-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-payment-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-productandoffer-impl\target\jacoco.exec
[INFO] Writing merged execution data to <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\target\jacoco.exec
[INFO]
以下是&#34; jacoco-aggregate&#34;的摘录。 POM:
<artifactId>jacoco-aggregate</artifactId>
<version>2.3.0-SNAPSHOT</version>
<name>jacoco-aggregate</name>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>com.att.detsusl</groupId>
<artifactId>usl-account-impl</artifactId>
<version>2.3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.att.detsusl</groupId>
<artifactId>usl-core-impl</artifactId>
<version>2.3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.att.detsusl</groupId>
<artifactId>usl-creditcheck-impl</artifactId>
<version>2.3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.att.detsusl</groupId>
<artifactId>usl-csi-jaxb-base</artifactId>
<version>2.3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.att.detsusl</groupId>
<artifactId>usl-ordercreation-impl</artifactId>
<version>2.3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.att.detsusl</groupId>
<artifactId>usl-payment-impl</artifactId>
<version>2.3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.att.detsusl</groupId>
<artifactId>usl-productandoffer-impl</artifactId>
<version>2.3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.att.detsusl</groupId>
<artifactId>usl-servicefactory-impl</artifactId>
<version>2.3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.att.detsusl</groupId>
<artifactId>usl-csi-icas-impl</artifactId>
<version>2.3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.8</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
<execution>
<id>merge</id>
<phase>verify</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${project.basedir}/../usl-account-impl/target</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../usl-core-impl/target</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../usl-creditcheck-impl/target</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../usl-csi-jaxb-base/target</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../usl-ordercreation-impl/target</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../usl-payment-impl/target</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../usl-productandoffer-impl/target</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../usl-servicefactory-impl/target</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
</fileSets>
</configuration>
</execution>
<execution>
<id>prepare-agent</id>
<phase>none</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-instrument</id>
<phase>none</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<phase>none</phase>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>none</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
请注意,我指定了其他jacoco目标的执行,因为那些是在父pom中指定的,预计将由普通代码模块使用。设置&#34;阶段&#34;到&#34;无&#34;是一种有效禁用该目标的方法(而不是它特别干净)。
在我使用&#34; jacoco-aggregate&#34;手动运行构建之前,我已经查看了几个&#34; jacoco.exec&#34;在其他模块中引用的文件,它们都存在且非空。
答案 0 :(得分:1)
首先 - 似乎你在merge
之后report-aggregate
,所以最后一个看不到jacoco.exec
。
另请注意report-aggregate
查看反应堆项目,即如果您有
root
\child_1
\child_2
然后在执行mvn ...
root
期间cd child_2 && mvn ...
将包含所有3个,而在执行child_2
期间,反应堆将只包含public class ChatAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
final int VIEW_TYPE_MESSAGE = 0;
final int VIEW_TYPE_IMAGE = 1;
Context context;
List<ChatWrapper> messages;
List<ImageDataWrapper> images;
public ChatAdapter(Context context, List<ChatWrapper> messages, List<ImageDataWrapper> images){
this.context = context;
this.messages = messages;
this.images = images;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
if(viewType == VIEW_TYPE_MESSAGE){
return new MessageViewHolder(itemView);
}
if(viewType == VIEW_TYPE_IMAGE){
return new ImageViewHolder(itemView);
}
return null;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position){
if(viewHolder instanceof MessageViewHolder){
((MessageViewHolder) viewHolder).populate(messages.get(position));
}
if(viewHolder instanceof ImageViewHolder){
((ImageViewHolder) viewHolder).populate(images.get(position - messages.size()));
}
}
@Override
public int getItemCount(){
return messages.size() + images.size();
}
@Override
public int getItemViewType(int position){
if(position < messages.size()){
return VIEW_TYPE_MESSAGE;
}
if(position - messages.size() < images.size()){
return VIEW_TYPE_IMAGE;
}
return -1;
}
public class MessageViewHolder extends RecyclerView.ViewHolder {
TextView message;
TextView timeStamp;
ImageView userImage;
public MessageViewHolder(View itemView){
super(itemView);
message = (TextView) itemView.findViewById(R.id.Single_Item_Chat_Message);
timeStamp = (TextView) itemView.findViewById(R.id.Single_Item_Chat_TimeStamp);
userImage = (ImageView) itemView.findViewById(R.id.Single_Item_Chat_ImageView);
}
public void populate(ChatWrapper chatWrapper){
message.setText(chatWrapper.getMessage());
userImage.setText(chatWrapper.getTimestamp());
}
}
public class ImageViewHolder extends RecyclerView.ViewHolder {
TextView dataTitle;
TextView dataLink;
TextView dataSnippet;
ImageView image;
ImageButton dataSendButton;
public ImageViewHolder(View itemView){
super(itemView);
dataTitle = (TextView) itemView.findViewById(R.id.Image_data_Title);
dataLink = (TextView) itemView.findViewById(R.id.Image_data_Link);
dataSnippet = (TextView) itemView.findViewById(R.id.Image_data_Snippet);
image = (ImageView) itemView.findViewById(R.id.Image_data_Image);
dataSendButton = (ImageButton) itemView.findViewById(R.id.Image_data_SendButton);
}
public void populate(ImageDataWrapper imageDataWrapper){
dataTitle.setText(imageDataWrapper.getPage_Title());
dataLink.setText(imageDataWrapper.getPage_Link());
dataSnippet.setText(imageDataWrapper.getPage_Desc());
Picasso.with(context).load(imageDataWrapper.getPage_ImageThumb()).into(image);
}
}
}
。