Skip to content
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ target
.idea
.classpath
.project
.settings
.settings
/.git-versioned-pom.xml
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 https://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>me.qoomon</groupId>
<artifactId>maven-git-versioning-extension</artifactId>
<version>9.6.5</version>
</extension>
</extensions>
22 changes: 22 additions & 0 deletions .mvn/maven-git-versioning-extension.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://github.com/qoomon/maven-git-versioning-extension" xsi:schemaLocation="https://github.com/qoomon/maven-git-versioning-extension https://qoomon.github.io/maven-git-versioning-extension/configuration-7.0.0.xsd">
<refs>
<ref type="branch">
<pattern>.+</pattern>
<!--
Uncomment following line when implementing Maven CI Friendly Versions: https://maven.apache.org/maven-ci-friendly.html
<version>${ref}-SNAPSHOT</version>
-->
<version>${version}</version>
</ref>

<ref type="tag">
<pattern><![CDATA[^v?(?<version>\d+\.\d+\.\d+.*)$]]></pattern>
<version>${ref.version}</version>
</ref>
</refs>

<!-- optional fallback configuration in case of no matching ref configuration-->
<rev>
<version>${commit}</version>
</rev>
</configuration>
28 changes: 28 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
</distributionManagement>

<properties>
<!-- Configuring for Reproducible Builds (cf. https://maven.apache.org/guides/mini/guide-reproducible-builds.html) -->
<!--suppress UnresolvedMavenProperty -->
<project.build.outputTimestamp>${git.commit.timestamp.datetime}</project.build.outputTimestamp>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand Down Expand Up @@ -123,6 +127,30 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addBuildEnvironmentEntries>true</addBuildEnvironmentEntries>
</manifest>
<manifestEntries>
<!--suppress UnresolvedMavenProperty -->
<Implementation-SCM-Revision-Number>${git.commit}</Implementation-SCM-Revision-Number>
<!--suppress UnresolvedMavenProperty -->
<Implementation-SCM-Revision-Date>${git.commit.timestamp.datetime}</Implementation-SCM-Revision-Date>
<!--suppress UnresolvedMavenProperty -->
<Implementation-Full-Version>${project.version}-${git.commit}</Implementation-Full-Version>
<Java-Version>${java.version}</Java-Version>
<Java-Vendor>${java.vendor}</Java-Vendor>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
55 changes: 31 additions & 24 deletions src/main/java/com/github/johnpoth/jshell/JShellMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
Expand All @@ -16,6 +16,14 @@
*/
package com.github.johnpoth.jshell;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;

import javax.tools.Tool;
import java.io.File;
import java.nio.file.Files;
Expand All @@ -26,18 +34,12 @@
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.stream.Collectors;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;

import static java.util.Optional.ofNullable;

@Mojo( name = "run", defaultPhase = LifecyclePhase.INSTALL, requiresDependencyResolution = ResolutionScope.TEST, requiresDependencyCollection = ResolutionScope.TEST )
public class JShellMojo extends AbstractMojo
{

@Mojo(name = "run", defaultPhase = LifecyclePhase.INSTALL, requiresDependencyResolution = ResolutionScope.TEST, requiresDependencyCollection = ResolutionScope.TEST)
public class JShellMojo extends AbstractMojo {

@Parameter(defaultValue = "${project.runtimeClasspathElements}", property = "rcp", required = true)
private List<String> runtimeClasspathElements;
Expand Down Expand Up @@ -121,12 +123,15 @@ private List<String> filterClasspath(List<String> cp) {
return cp.stream()
.filter(s -> {
Path path = Paths.get(s);
if (Files.notExists(path)){
getLog().warn("Removing: " + s +" from the classpath." + System.lineSeparator() +
"If this is unexpected, please make sure you correctly build the project beforehand by invoking the correct Maven build phase (usually `install`, `test-compile` or `compile`). For example:" + System.lineSeparator() +
"mvn test-compile com.github.johnpoth:jshell-maven-plugin:1.3:run" + System.lineSeparator() +
"For more information visit https://github.com/johnpoth/jshell-maven-plugin"
);
if (Files.notExists(path)) {
getLog().info(String.format(
"Removing: %s from the classpath.%n" +
"If this is unexpected, please make sure you correctly build the project beforehand by invoking the correct Maven build phase (usually `install`, `test-compile` or `compile`). For example:%n" +
"mvn test-compile com.github.johnpoth:jshell-maven-plugin:%s:run%n" +
"For more information visit https://github.com/johnpoth/jshell-maven-plugin",
s,
ofNullable(this.getClass().getPackage().getImplementationVersion()).orElse("RELEASE")
));
return false;
}
if (Files.isDirectory(path)) {
Expand All @@ -135,7 +140,9 @@ private List<String> filterClasspath(List<String> cp) {
if (s.endsWith(".jar")) {
return true;
}
getLog().debug("Removing: " + s +" from the classpath because it is unsupported in JShell.");
if (getLog().isDebugEnabled()) {
getLog().debug("Removing: " + s + " from the classpath because it is unsupported in JShell.");
}
return false;
}).collect(Collectors.toList());
}
Expand All @@ -145,19 +152,19 @@ private String[] addArguments(String cp) {
if (useProjectClasspath) {
args.add("--class-path");
args.add(cp);
} else if (classpath != null ){
} else if (classpath != null) {
args.add("--class-path");
args.add(classpath);
}
if (modulepath != null){
if (modulepath != null) {
args.add("--module-path");
args.add(modulepath);
}
if (addModules!= null){
if (addModules != null) {
args.add("--add-modules");
args.add(addModules);
}
if (addExports!= null){
if (addExports != null) {
args.add("--add-exports");
args.add(addExports);
}
Expand Down