Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2000-2025 Vaadin Ltd.
#
# Licensed 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.
#

invoker.goals=clean flow:prepare-frontend
invoker.buildResult=success
54 changes: 54 additions & 0 deletions flow-plugins/flow-maven-plugin/src/it/vaadin-skip-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>

<groupId>com.vaadin.test.maven</groupId>
<artifactId>vaadin-skip-test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<description>
Tests the vaadin.skip parameter functionality.
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.source>${maven.compiler.release}</maven.compiler.source>
<maven.compiler.target>${maven.compiler.release}</maven.compiler.target>
<maven.test.skip>true</maven.test.skip>
<flow.version>@project.version@</flow.version>
</properties>

<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-server</artifactId>
<version>${flow.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-client</artifactId>
<version>${flow.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>flow-maven-plugin</artifactId>
<version>${flow.version}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.vaadin.test;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.router.Route;

@Route
public class SkipTestView extends Component {

}
13 changes: 13 additions & 0 deletions flow-plugins/flow-maven-plugin/src/it/vaadin-skip-test/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.nio.file.*;

flowTsx = basedir.toPath().resolve("build.log");
if ( !Files.exists(flowTsx, new LinkOption[0]) )
{
throw new RuntimeException("build.log not found");
}

lines = Files.readString(flowTsx);
if ( !lines.contains("Skipping Vaadin build") )
{
throw new RuntimeException("Vaadin build not skipped");
}
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ public abstract class FlowModeAbstractMojo extends AbstractMojo
+ InitParameters.COMMERCIAL_WITH_BANNER, defaultValue = "false")
private boolean commercialWithBanner;

/**
* Skip the execution of this plugin.
*/
@Parameter(property = "vaadin.skip", defaultValue = "false")
private boolean skip;

static final String CLASSFINDER_FIELD_NAME = "classFinder";
private ClassFinder classFinder;

Expand All @@ -325,6 +331,11 @@ void setBuildContext(BuildContext buildContext) {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping Vaadin build");
return;
}

PluginDescriptor pluginDescriptor = mojoExecution.getMojoDescriptor()
.getPluginDescriptor();
checkFlowCompatibility(pluginDescriptor);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Copyright 2000-2025 Vaadin Ltd.
*
* Licensed 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.
*/
package com.vaadin.flow.plugin.maven;

import java.io.File;

import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.ReflectionUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.Mockito;

import static com.vaadin.flow.plugin.maven.BuildFrontendMojoTest.setProject;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

public class SkipExecutionTest {

@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();

private PrepareFrontendMojo mojo;
private Log mockLog;
private File projectBase;

@Before
public void setup() throws Exception {
mojo = new PrepareFrontendMojo();
mockLog = Mockito.mock(Log.class);
projectBase = temporaryFolder.getRoot();

// Set up the mojo with basic configuration
ReflectionUtils.setVariableValueInObject(mojo, "projectBasedir",
projectBase);
ReflectionUtils.setVariableValueInObject(mojo, "frontendDirectory",
new File(projectBase, "src/main/frontend"));

setProject(mojo, projectBase);

// Use reflection to set the mock logger
ReflectionUtils.setVariableValueInObject(mojo, "log", mockLog);
}

@Test
public void testSkipExecutionWhenVaadinSkipIsTrue() throws Exception {
// Set the skip parameter to true
ReflectionUtils.setVariableValueInObject(mojo, "skip", true);

// Execute the mojo
mojo.execute();

// Verify that the skip message was logged
verify(mockLog).info("Skipping Vaadin build");
}

@Test
public void testNormalExecutionWhenVaadinSkipIsFalse() throws Exception {
// Set the skip parameter to false (default)
ReflectionUtils.setVariableValueInObject(mojo, "skip", false);

try {
// Execute the mojo - this might fail due to missing dependencies in
// test env
mojo.execute();
} catch (Exception e) {
// Expected - we're just testing that skip message is not logged
}

// Verify that the skip message was NOT logged
verify(mockLog, never()).info("Skipping Vaadin build");
}
}
Loading