Comments (11)
@khmarbaise wrote:
I know that the provided scope is not available on the classpath cause it's defined provided which means it is provided by the runtime environment.
For exec:java there isn't usually anywhere else that the provided dependencies could come from unless they actually part of the standard java libraries. ie. built-in classes. The request in #61 is to make the provided depdendencies available in the runtime.
While the "provided" dependencies might be expected to be available in normal/exepcted execution circumstances it seems reasonable for exec:java to act as "provider" of these dependencies if it is acting as the execution container. Since exec:java is the execution container and the "provided" and "optional" dependencies won't otherwise be available it might even be argued that including them should be the default behaviour of exec:java.
from exec-maven-plugin.
@lbreuss The PR #61 has been ignored so far. At some point merge conflicts evolved from changes in master branch. I have just resolved those. If the builds succeed, the PR will again be ready to merge.
from exec-maven-plugin.
@bondolo Exactly! For local development purposes it's often useful to be able to run an app and use Maven to supply the "provided" dependencies rather than using the full deployment environment.
from exec-maven-plugin.
Based on the answer on SO it does not make sense. Or you you could provide a patch (as PR) ?
from exec-maven-plugin.
Try using the below POM along with a main class called "Main".
If you run mvn exec:java -P runtime
, you get:
java.lang.NoClassDefFoundError: org/apache/log4j/Level
indicating that the "provided" dependency is not available.
If you run mvn exec:java -P compile
, you get:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
indicating that the "runtime" dependency is not available.
I can attempt to make a PR to help fix this, but I could use some input on what the configuration should look like. Should we add a new value for "classpathScope" called "provided" which includes both runtime and provided?
<?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.nnoncarey.sha</groupId>
<artifactId>maven-exec-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>runtime</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>Main</mainClass>
<executable>java</executable>
<classpathScope>runtime</classpathScope>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>compile</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>Main</mainClass>
<executable>java</executable>
<classpathScope>compile</classpathScope>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
from exec-maven-plugin.
I know that the provided scope is not available on the classpath cause it's defined provided which means it is provided by the runtime environment. That was the reason that i said you could provide a patch which solves this problem ?
from exec-maven-plugin.
Oh, it sounded like you thought it made no sense. I can attempt a patch, but as I asked above, do you care what the configuration setting should be? Is "provided" ok as a new value for classpathScope?
from exec-maven-plugin.
@khmarbaise #61 created to resolve this.
from exec-maven-plugin.
@rehevkor5 What is the status of your merge request? Has it been cancelled or ignored?
This feature would be very welcome. My software references org.slf4j:slf4j-api:provided, and some :runtime dependencies down the road... Currently, I cannot run the application, as either scope "compile" or scope "runtime" will miss one or the other dependency...
from exec-maven-plugin.
I pinged @rfscholte and @khmarbaise on twitter. It appears this issue is at an impasse unless @olamy is able to approve. This project seems to need new/additional maintainers.
from exec-maven-plugin.
I know that the provided scope is not available on the classpath cause it's defined provided which means it is provided by the runtime environment. That was the reason that i said you could provide a patch which solves this problem ?
I guess there are use cases where you could consider exec-maven-plugin
as the runtime environment.
from exec-maven-plugin.
Related Issues (20)
- ClassNotFoundException when dynamically loading a Java class executed by exec-maven-plugin HOT 2
- Non-Uppercase Environment Variables duplicated with an Uppercase version HOT 6
- Idea: Add dll dependencies to java.library.path
- Passing argument -p to java application HOT 1
- Module path can't be defined HOT 1
- An default visibility class, has main method, occurs error on execution HOT 2
- add third execution mode to enable jvm parameters such as --enable-preview HOT 4
- Plugin does not use jdk from toolchains plugin HOT 1
- IOException: Stream closed HOT 2
- Failing to execute goal after upgrading to Java 17 with ExecuteException HOT 1
- mavin plugin file HOT 1
- git submodule status fails with exec-maven-plugin:3.1.0 but succeeds with exec-maven-plugin:1.6.0:exec HOT 2
- Doing several invocations through exec:java? HOT 19
- New option 'blockSystemExit' for 'java' mojo
- Properly handle UnsupportedOperationException thrown by Thread::stop in JDK 20+ HOT 3
- XML DocumentBuilderFactory error after upgrade from 3.0.0 to 3.1.0 HOT 5
- setting MAVEN_OPTS in environment variables does not work
- how to pass command line arguments to exec:java as pom.xml variable/ parameter?
- Shell script execution using "basedir" as argument has problems in Windows
- NullPointerException under Maven 4.0.0-m10 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exec-maven-plugin.