Skip to content

Commit

Permalink
merge upstream/master into 458-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinayagarwal committed Sep 13, 2023
2 parents c9851d6 + c74739f commit c189884
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.PAT }}
generate_release_notes: true

- name: Commit next development version
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/com/gluonhq/NativeBaseMojo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022, Gluon
* Copyright (c) 2019, 2023, Gluon
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -36,6 +36,7 @@
import com.gluonhq.substrate.SubstrateDispatcher;
import com.gluonhq.substrate.model.Triplet;
import com.gluonhq.substrate.target.WebTargetConfiguration;
import com.gluonhq.substrate.util.Version;
import com.gluonhq.utils.MavenArtifactResolver;
import org.apache.commons.exec.ProcessDestroyer;
import org.apache.commons.exec.ShutdownHookProcessDestroyer;
Expand All @@ -49,6 +50,7 @@
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.rtinfo.RuntimeInformation;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.graph.DependencyFilter;

Expand All @@ -72,6 +74,9 @@ public abstract class NativeBaseMojo extends AbstractMojo {

private static final List<String> ALLOWED_DEPENDENCY_TYPES = Collections.singletonList("jar");

// TODO: Remove this restriction when MavenArtifactResolver works with Maven 3.9.0+
private static final Version MAX_SUPPORTED_MAVEN_VERSION = new Version(3, 8, 8);

Path outputDir;

@Parameter(defaultValue = "${project}", readonly = true)
Expand All @@ -83,6 +88,9 @@ public abstract class NativeBaseMojo extends AbstractMojo {
@Component
BuildPluginManager pluginManager;

@Component
private RuntimeInformation runtimeInformation;

@Parameter(readonly = true, required = true, defaultValue = "${basedir}")
File basedir;

Expand Down Expand Up @@ -149,6 +157,12 @@ public abstract class NativeBaseMojo extends AbstractMojo {
private ProcessDestroyer processDestroyer;

public SubstrateDispatcher createSubstrateDispatcher() throws IOException, MojoExecutionException {
String mavenVersion = runtimeInformation.getMavenVersion();
Version version = new Version(mavenVersion);
if (version.compareTo(MAX_SUPPORTED_MAVEN_VERSION) > 0) {
throw new MojoExecutionException("Maven version " + mavenVersion + " is not currently supported by the GluonFX Maven Plugin.\n" +
"Please downgrade your Maven version to " + MAX_SUPPORTED_MAVEN_VERSION + " and then try again.\n");
}
if (getGraalvmHome().isEmpty()) {
throw new MojoExecutionException("GraalVM installation directory not found." +
" Either set GRAALVM_HOME as an environment variable or" +
Expand Down
60 changes: 60 additions & 0 deletions src/main/java/com/gluonhq/NativeStaticLibMojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2023, Gluon
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.gluonhq;

import com.gluonhq.substrate.SubstrateDispatcher;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;

@Mojo(name = "staticlib", defaultPhase = LifecyclePhase.COMPILE,
requiresDependencyResolution = ResolutionScope.COMPILE)
@Execute(phase = LifecyclePhase.PROCESS_CLASSES)
public class NativeStaticLibMojo extends NativeBaseMojo {

@Override
public void execute() throws MojoExecutionException {
boolean result;
try {
SubstrateDispatcher dispatcher = createSubstrateDispatcher();
result = dispatcher.nativeStaticLibrary();
} catch (Exception e) {
e.printStackTrace();
throw new MojoExecutionException("Error", e);
}

if (!result) {
throw new MojoExecutionException("Native static library failed");
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/gluonhq/utils/MavenArtifactResolver.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021, Gluon
* Copyright (c) 2019, 2023, Gluon
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -149,6 +149,7 @@ public static void initRepositories(List<Repository> repositories) {
instance = new MavenArtifactResolver(repositories);
}

// TODO: Find an alternative, as this only works up until Maven 3.8.7.
private RepositorySystem createRepositorySystem() {
DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils.newServiceLocator();
serviceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
Expand Down

0 comments on commit c189884

Please sign in to comment.