This is an automated email from the ASF dual-hosted git repository. tibordigana pushed a commit to branch 1546-1222 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit e26a03e909e073e9d66936aa4444bceb69356086 Author: tibordigana <[email protected]> AuthorDate: Thu Apr 11 18:52:08 2019 +0200 started with extensions --- maven-surefire-common/pom.xml | 5 ++ .../plugin/surefire/AbstractSurefireMojo.java | 8 +++ .../plugin/surefire/extensions/DefaultShader.java | 53 +++++++++++++++ .../extensions/DefaultStatelessReporter.java | 38 +++++++++++ .../maven/plugin/surefire/extensions/Shader.java | 30 +++++++++ .../extensions/StatelessReporterEvent.java | 58 ++++++++++++++++ .../surefire/report/StatelessXmlReporter.java | 10 ++- pom.xml | 1 + surefire-extensions-api/pom.xml | 48 +++++++++++++ .../extensions/StatelessReportEventListener.java | 48 +++++++++++++ .../surefire/extensions/StatelessReporter.java | 78 ++++++++++++++++++++++ 11 files changed, 376 insertions(+), 1 deletion(-) diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml index 770642e..18fed62 100644 --- a/maven-surefire-common/pom.xml +++ b/maven-surefire-common/pom.xml @@ -44,6 +44,11 @@ </dependency> <dependency> <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-extensions-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-booter</artifactId> <version>${project.version}</version> </dependency> diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java index 856a527..a3cec45 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java @@ -25,6 +25,7 @@ import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Dependency; +import org.apache.maven.plugin.surefire.extensions.Shader; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.RepositorySystem; @@ -69,6 +70,7 @@ import org.apache.maven.surefire.booter.StartupConfiguration; import org.apache.maven.surefire.booter.SurefireBooterForkException; import org.apache.maven.surefire.booter.SurefireExecutionException; import org.apache.maven.surefire.cli.CommandLineOption; +import org.apache.maven.surefire.extensions.StatelessReporter; import org.apache.maven.surefire.providerapi.SurefireProvider; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.suite.RunResult; @@ -156,6 +158,12 @@ public abstract class AbstractSurefireMojo private final ProviderDetector providerDetector = new ProviderDetector(); + // @Component( hint = "default", role = StatelessReporter.class ) + private StatelessReporter statelessReporter; + + @Component( hint = "default", role = Shader.class ) + private Shader shader; + /** * Information about this plugin, mainly used to lookup this plugin's configuration from the currently executing * project. diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultShader.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultShader.java new file mode 100644 index 0000000..8230ad4 --- /dev/null +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultShader.java @@ -0,0 +1,53 @@ +package org.apache.maven.plugin.surefire.extensions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// import org.codehaus.plexus.component.annotations.Component; +// import org.codehaus.plexus.component.annotations.Configuration; +import org.codehaus.plexus.logging.AbstractLogEnabled; + +/** + * @author Jason van Zyl + */ +// @Component( role = Shader.class, hint = "default" ) +public class DefaultShader + extends AbstractLogEnabled + implements Shader +{ + + // @Configuration( "false" ) + private boolean disableXmlReport; + + public boolean isDisableXmlReport() + { + return disableXmlReport; + } + + public void setDisableXmlReport( boolean disableXmlReport ) + { + this.disableXmlReport = disableXmlReport; + } + + @Override + public void shade() + { + + } +} diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultStatelessReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultStatelessReporter.java new file mode 100644 index 0000000..3838272 --- /dev/null +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultStatelessReporter.java @@ -0,0 +1,38 @@ +package org.apache.maven.plugin.surefire.extensions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.extensions.StatelessReportEventListener; +import org.apache.maven.surefire.extensions.StatelessReporter; +// import org.codehaus.plexus.component.annotations.Component; + +/** + * author <a href="mailto:[email protected]">Tibor Digana (tibor17)</a> + * @since 3.0.0-M4 + */ +// @Component( role = StatelessReporter.class, hint = "default" ) +public class DefaultStatelessReporter extends StatelessReporter<StatelessReporterEvent> +{ + @Override + public StatelessReportEventListener<StatelessReporterEvent> createStatelessReportEventListener() + { + return null; + } +} diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/Shader.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/Shader.java new file mode 100644 index 0000000..fce55f0 --- /dev/null +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/Shader.java @@ -0,0 +1,30 @@ +package org.apache.maven.plugin.surefire.extensions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Interface that defines the process of shading. + */ +public interface Shader +{ + String ROLE = Shader.class.getName(); + + void shade(); +} diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/StatelessReporterEvent.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/StatelessReporterEvent.java new file mode 100644 index 0000000..7e87052 --- /dev/null +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/StatelessReporterEvent.java @@ -0,0 +1,58 @@ +package org.apache.maven.plugin.surefire.extensions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.plugin.surefire.report.TestSetStats; +import org.apache.maven.plugin.surefire.report.WrappedReportEntry; + +import java.util.EventObject; + +/** + * author <a href="mailto:[email protected]">Tibor Digana (tibor17)</a> + * @since 3.0.0-M4 + */ +public final class StatelessReporterEvent extends EventObject +{ + private final WrappedReportEntry testSetReportEntry; + private final TestSetStats testSetStats; + + /** + * Constructs a prototypical Event. + * + * @param source The object on which the Event initially occurred. + * @throws IllegalArgumentException if source is null. + */ + public StatelessReporterEvent( Object source, WrappedReportEntry testSetReportEntry, TestSetStats testSetStats ) + { + super( source ); + this.testSetReportEntry = testSetReportEntry; + this.testSetStats = testSetStats; + } + + public WrappedReportEntry getTestSetReportEntry() + { + return testSetReportEntry; + } + + public TestSetStats getTestSetStats() + { + return testSetStats; + } +} diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java index 5052f84..c5f7842 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java @@ -20,8 +20,10 @@ package org.apache.maven.plugin.surefire.report; */ import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton; +import org.apache.maven.plugin.surefire.extensions.StatelessReporterEvent; import org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter; import org.apache.maven.shared.utils.xml.XMLWriter; +import org.apache.maven.surefire.extensions.StatelessReportEventListener; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.SafeThrowable; @@ -83,7 +85,7 @@ import static org.apache.maven.surefire.util.internal.StringUtils.isBlank; * (not yet implemented by Ant 1.8.2) */ @Deprecated // this is no more stateless due to existence of testClassMethodRunHistoryMap since of 2.19. Rename to StatefulXmlReporter in 3.0. -public class StatelessXmlReporter +public class StatelessXmlReporter implements StatelessReportEventListener<StatelessReporterEvent> { private final File reportsDirectory; @@ -112,6 +114,12 @@ public class StatelessXmlReporter this.xsdSchemaLocation = xsdSchemaLocation; } + @Override + public void testSetCompleted( StatelessReporterEvent event ) + { + testSetCompleted( event.getTestSetReportEntry(), event.getTestSetStats() ); + } + public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStats testSetStats ) { Map<String, Map<String, List<WrappedReportEntry>>> classMethodStatistics = diff --git a/pom.xml b/pom.xml index 740357a..0d380ef 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,7 @@ <module>maven-failsafe-plugin</module> <module>maven-surefire-report-plugin</module> <module>surefire-its</module> + <module>surefire-extensions-api</module> </modules> <scm> diff --git a/surefire-extensions-api/pom.xml b/surefire-extensions-api/pom.xml new file mode 100644 index 0000000..a2bce4e --- /dev/null +++ b/surefire-extensions-api/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire</artifactId> + <version>3.0.0-SNAPSHOT</version> + </parent> + + <artifactId>surefire-extensions-api</artifactId> + + <dependencies> + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-component-annotations</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + +</project> \ No newline at end of file diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReportEventListener.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReportEventListener.java new file mode 100644 index 0000000..f5610a4 --- /dev/null +++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReportEventListener.java @@ -0,0 +1,48 @@ +package org.apache.maven.surefire.extensions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.EventListener; +import java.util.EventObject; + +/** + * Creates a report upon handled event "<em>testSetCompleted</em>". + * <br> + * Defaults to <em>org.apache.maven.plugin.surefire.report.StatelessXmlReporter</em>. + * + * author <a href="mailto:[email protected]">Tibor Digana (tibor17)</a> + * @since 3.0.0-M4 + * @param <T> Generic type of event type + */ +public interface StatelessReportEventListener<T extends EventObject> + extends EventListener +{ + /** + * Event handled after the test class has been completed and the state of report is final. + * <br> + * The {@code event} (of type <em>org.apache.maven.plugin.surefire.extensions.StatelessReporterEvent</em>) + * wraps <em>WrappedReportEntry</em> and <em>TestSetStats</em> from the module <em>maven-surefire-common</em>. + * <br> + * The {@link EventObject#getSource()} may access <em>TestSetRunListener</em> object or returns <tt>null</tt>. + * + * @param event event wrapper (type can be changed between major or minor versions) + */ + void testSetCompleted( T event ); +} diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReporter.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReporter.java new file mode 100644 index 0000000..908d1a6 --- /dev/null +++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReporter.java @@ -0,0 +1,78 @@ +package org.apache.maven.surefire.extensions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// import org.codehaus.plexus.component.annotations.Configuration; + +import java.io.File; +import java.util.EventObject; + +/** + * @author <a href="mailto:[email protected]">Tibor Digana (tibor17)</a> + * @since 3.0.0-M4 + * @param <T> Generic type of event type + */ +public abstract class StatelessReporter<T extends EventObject> +{ + public static final String ROLE = StatelessReporter.class.getName(); + + // @Configuration( "false" ) + private boolean disableXmlReport; + + private File reportsDirectory; + private boolean trimStackTrace; + + /** + * Creates reporter. + * + * @return reporter object + */ + public abstract StatelessReportEventListener<T> createStatelessReportEventListener(); + + public boolean isDisableXmlReport() + { + return disableXmlReport; + } + + public void setDisableXmlReport( boolean disableXmlReport ) + { + this.disableXmlReport = disableXmlReport; + } + + public File getReportsDirectory() + { + return reportsDirectory; + } + + public void setReportsDirectory( File reportsDirectory ) + { + this.reportsDirectory = reportsDirectory; + } + + public boolean isTrimStackTrace() + { + return trimStackTrace; + } + + public void setTrimStackTrace( boolean trimStackTrace ) + { + this.trimStackTrace = trimStackTrace; + } +}
