Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFMP-191] Add a dev goal for rapid development of WAR files. #291

Merged
merged 2 commits into from
Mar 8, 2023
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
6 changes: 6 additions & 0 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
</dependency>

<dependency>
<groupId>org.twdata.maven</groupId>
<artifactId>mojo-executor</artifactId>
<version>${version.org.twdata.maven}</version>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-controller-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ public static String getJavaCommand(final Path javaHome) {
return exe;
}

/**
* Determines if this is a Windows environment.
*
* @return {@code true} if this is a Windows environment, otherwise {@code false}
*/
public static boolean isWindows() {
return WINDOWS;
}

private static Path findJavaHome() {
String path = WildFlySecurityManager.getPropertyPrivileged("java.home", null);
if (path != null) {
Expand Down
25 changes: 25 additions & 0 deletions plugin/src/main/java/org/wildfly/plugin/common/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

package org.wildfly.plugin.common;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
Expand All @@ -33,6 +36,8 @@
public class Utils {
private static final Pattern EMPTY_STRING = Pattern.compile("^$|\\s+");

private static final Pattern WHITESPACE_IF_NOT_QUOTED = Pattern.compile("(\\S+\"[^\"]+\")|\\S+");

public static final String WILDFLY_DEFAULT_DIR= "server";
/**
* Tests if the character sequence is not {@code null} and not empty.
Expand Down Expand Up @@ -75,4 +80,24 @@ public static String toString(final Iterable<?> iterable, final CharSequence del
}
return result.toString();
}

/**
* Splits the arguments into a list. The arguments are split based on whitespace while ignoring whitespace that is
* within quotes.
*
* @param arguments the arguments to split
*
* @return the list of the arguments
*/
public static List<String> splitArguments(final CharSequence arguments) {
final List<String> args = new ArrayList<>();
final Matcher m = WHITESPACE_IF_NOT_QUOTED.matcher(arguments);
while (m.find()) {
final String value = m.group();
if (!value.isEmpty()) {
args.add(value);
}
}
return args;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* JBoss, Home of Professional Open Source.
*
* Copyright 2023 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* 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 org.wildfly.plugin.dev;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.WatchEvent;

import org.apache.maven.plugin.MojoExecutionException;

/**
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
*/
class CompiledSourceHandler implements WatchHandler {

@Override
public Result handle(final WatchContext context, final WatchEvent<Path> event, final Path file) throws IOException, MojoExecutionException {
return new Result() {
@Override
public boolean requiresRecompile() {
return true;
}

@Override
public boolean requiresRedeploy() {
return true;
}

@Override
public boolean requiresRepackage() {
return true;
}
};
}
}
Loading