lendingclub / gradle-maven-plugin Goto Github PK
View Code? Open in Web Editor NEWmaven plugin to invoke gradle
maven plugin to invoke gradle
Gradle is not installed in my system
Getting the following exception on both mac and rhel while running mvn compile
mvn -X compile
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG] Imported: javax.enterprise.inject.* < plexus.core
[DEBUG] Imported: javax.enterprise.util.* < plexus.core
[DEBUG] Imported: javax.inject.* < plexus.core
[DEBUG] Imported: org.apache.maven.* < plexus.core
[DEBUG] Imported: org.apache.maven.artifact < plexus.core
[DEBUG] Imported: org.apache.maven.classrealm < plexus.core
[DEBUG] Imported: org.apache.maven.cli < plexus.core
[DEBUG] Imported: org.apache.maven.configuration < plexus.core
[DEBUG] Imported: org.apache.maven.exception < plexus.core
[DEBUG] Imported: org.apache.maven.execution < plexus.core
[DEBUG] Imported: org.apache.maven.execution.scope < plexus.core
[DEBUG] Imported: org.apache.maven.lifecycle < plexus.core
[DEBUG] Imported: org.apache.maven.model < plexus.core
[DEBUG] Imported: org.apache.maven.monitor < plexus.core
[DEBUG] Imported: org.apache.maven.plugin < plexus.core
[DEBUG] Imported: org.apache.maven.profiles < plexus.core
[DEBUG] Imported: org.apache.maven.project < plexus.core
[DEBUG] Imported: org.apache.maven.reporting < plexus.core
[DEBUG] Imported: org.apache.maven.repository < plexus.core
[DEBUG] Imported: org.apache.maven.rtinfo < plexus.core
[DEBUG] Imported: org.apache.maven.settings < plexus.core
[DEBUG] Imported: org.apache.maven.toolchain < plexus.core
[DEBUG] Imported: org.apache.maven.usability < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.* < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.authentication < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.authorization < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.events < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.observers < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.proxy < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.repository < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.resource < plexus.core
[DEBUG] Imported: org.codehaus.classworlds < plexus.core
[DEBUG] Imported: org.codehaus.plexus.* < plexus.core
[DEBUG] Imported: org.codehaus.plexus.classworlds < plexus.core
[DEBUG] Imported: org.codehaus.plexus.component < plexus.core
[DEBUG] Imported: org.codehaus.plexus.configuration < plexus.core
[DEBUG] Imported: org.codehaus.plexus.container < plexus.core
[DEBUG] Imported: org.codehaus.plexus.context < plexus.core
[DEBUG] Imported: org.codehaus.plexus.lifecycle < plexus.core
[DEBUG] Imported: org.codehaus.plexus.logging < plexus.core
[DEBUG] Imported: org.codehaus.plexus.personality < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core
[DEBUG] Imported: org.eclipse.aether.* < plexus.core
[DEBUG] Imported: org.eclipse.aether.artifact < plexus.core
[DEBUG] Imported: org.eclipse.aether.collection < plexus.core
[DEBUG] Imported: org.eclipse.aether.deployment < plexus.core
[DEBUG] Imported: org.eclipse.aether.graph < plexus.core
[DEBUG] Imported: org.eclipse.aether.impl < plexus.core
[DEBUG] Imported: org.eclipse.aether.installation < plexus.core
[DEBUG] Imported: org.eclipse.aether.internal.impl < plexus.core
[DEBUG] Imported: org.eclipse.aether.metadata < plexus.core
[DEBUG] Imported: org.eclipse.aether.repository < plexus.core
[DEBUG] Imported: org.eclipse.aether.resolution < plexus.core
[DEBUG] Imported: org.eclipse.aether.spi < plexus.core
[DEBUG] Imported: org.eclipse.aether.transfer < plexus.core
[DEBUG] Imported: org.eclipse.aether.version < plexus.core
[DEBUG] Imported: org.slf4j.* < plexus.core
[DEBUG] Imported: org.slf4j.helpers.* < plexus.core
[DEBUG] Imported: org.slf4j.spi.* < plexus.core
[DEBUG] Populating class realm maven.api
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /usr/local/Cellar/maven/3.3.9/libexec/conf/settings.xml
[DEBUG] Reading user settings from /Users/pmandala/.m2/settings.xml
[DEBUG] Reading global toolchains from /usr/local/Cellar/maven/3.3.9/libexec/conf/toolchains.xml
[DEBUG] Reading user toolchains from /Users/pmandala/.m2/toolchains.xml
[DEBUG] Using local repository at /Users/pmandala/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/pmandala/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project com.oracle.bdcsce:bdcsce-dist:pom:1.0-SNAPSHOT: (none)
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project com.oracle.bdcsce:spark-cloud-service:pom:1.0-SNAPSHOT: (none)
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] === REACTOR BUILD PLAN ================================================
[DEBUG] Project: com.oracle.bdcsce:bdcsce-dist:pom:1.0-SNAPSHOT
[DEBUG] Tasks: [compile]
[DEBUG] Style: Regular
[DEBUG] =======================================================================
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building BDCSCE Distribution 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] === PROJECT BUILD PLAN ================================================
[DEBUG] Project: com.oracle.bdcsce:bdcsce-dist:1.0-SNAPSHOT
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): []
[DEBUG] Repositories (dependencies): [slc-artifactory (https://artifactory-slc.oraclecorp.com/artifactory/bdcsce-snapshot-local/, default, releases+snapshots), central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] Repositories (plugins) : [central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.fortasoft:gradle-maven-plugin:1.0.8:invoke (default)
[DEBUG] Style: Regular
[DEBUG] Configuration:
hello
[DEBUG] =======================================================================
[INFO]
[INFO] --- gradle-maven-plugin:1.0.8:invoke (default) @ bdcsce-dist ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=1, ConflictMarker.markTime=0, ConflictMarker.nodeCount=81, ConflictIdSorter.graphTime=1, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=33, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=6, ConflictResolver.conflictItemCount=79, DefaultDependencyCollector.collectTime=235, DefaultDependencyCollector.transformTime=10}
[DEBUG] org.fortasoft:gradle-maven-plugin:jar:1.0.8:
[DEBUG] org.apache.maven:maven-plugin-api:jar:3.3.9:compile
[DEBUG] org.apache.maven:maven-model:jar:3.3.9:compile
[DEBUG] org.apache.maven:maven-artifact:jar:3.3.9:compile
[DEBUG] org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.2:compile
[DEBUG] javax.enterprise:cdi-api:jar:1.0:compile
[DEBUG] javax.annotation:jsr250-api:jar:1.0:compile
[DEBUG] org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.2:compile
[DEBUG] org.apache.maven:maven-core:jar:3.3.9:compile
[DEBUG] org.apache.maven:maven-settings:jar:3.3.9:compile
[DEBUG] org.apache.maven:maven-settings-builder:jar:3.3.9:compile
[DEBUG] org.apache.maven:maven-builder-support:jar:3.3.9:compile
[DEBUG] org.apache.maven:maven-repository-metadata:jar:3.3.9:compile
[DEBUG] org.apache.maven:maven-model-builder:jar:3.3.9:compile
[DEBUG] com.google.guava:guava:jar:18.0:compile
[DEBUG] org.apache.maven:maven-aether-provider:jar:3.3.9:compile
[DEBUG] org.eclipse.aether:aether-spi:jar:1.0.2.v20150114:compile
[DEBUG] org.eclipse.aether:aether-impl:jar:1.0.2.v20150114:compile
[DEBUG] org.eclipse.aether:aether-api:jar:1.0.2.v20150114:compile
[DEBUG] org.eclipse.aether:aether-util:jar:1.0.2.v20150114:compile
[DEBUG] com.google.inject:guice:jar:no_aop:4.0:compile
[DEBUG] javax.inject:javax.inject:jar:1:compile
[DEBUG] aopalliance:aopalliance:jar:1.0:compile
[DEBUG] org.codehaus.plexus:plexus-interpolation:jar:1.21:compile
[DEBUG] org.codehaus.plexus:plexus-utils:jar:3.0.22:compile
[DEBUG] org.codehaus.plexus:plexus-classworlds:jar:2.5.2:compile
[DEBUG] org.codehaus.plexus:plexus-component-annotations:jar:1.6:compile
[DEBUG] org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[DEBUG] org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[DEBUG] org.apache.commons:commons-lang3:jar:3.4:compile
[DEBUG] org.slf4j:slf4j-api:jar:1.7.5:compile
[DEBUG] org.gradle:gradle-tooling-api:jar:2.13:compile
[DEBUG] org.codehaus.groovy:groovy-all:jar:2.0.6:compile
[DEBUG] Created new class realm plugin>org.fortasoft:gradle-maven-plugin:1.0.8
[DEBUG] Importing foreign packages into class realm plugin>org.fortasoft:gradle-maven-plugin:1.0.8
[DEBUG] Imported: < maven.api
[DEBUG] Populating class realm plugin>org.fortasoft:gradle-maven-plugin:1.0.8
[DEBUG] Included: org.fortasoft:gradle-maven-plugin:jar:1.0.8
[DEBUG] Included: javax.enterprise:cdi-api:jar:1.0
[DEBUG] Included: javax.annotation:jsr250-api:jar:1.0
[DEBUG] Included: org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.2
[DEBUG] Included: org.apache.maven:maven-builder-support:jar:3.3.9
[DEBUG] Included: com.google.guava:guava:jar:18.0
[DEBUG] Included: org.eclipse.aether:aether-util:jar:1.0.2.v20150114
[DEBUG] Included: com.google.inject:guice:jar:no_aop:4.0
[DEBUG] Included: aopalliance:aopalliance:jar:1.0
[DEBUG] Included: org.codehaus.plexus:plexus-interpolation:jar:1.21
[DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:3.0.22
[DEBUG] Included: org.codehaus.plexus:plexus-component-annotations:jar:1.6
[DEBUG] Included: org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3
[DEBUG] Included: org.sonatype.plexus:plexus-cipher:jar:1.4
[DEBUG] Included: org.apache.commons:commons-lang3:jar:3.4
[DEBUG] Included: org.gradle:gradle-tooling-api:jar:2.13
[DEBUG] Included: org.codehaus.groovy:groovy-all:jar:2.0.6
[DEBUG] Configuring mojo org.fortasoft:gradle-maven-plugin:1.0.8:invoke from plugin realm ClassRealm[plugin>org.fortasoft:gradle-maven-plugin:1.0.8, parent: sun.misc.Launcher$AppClassLoader@135fbaa4]
[DEBUG] Configuring mojo 'org.fortasoft:gradle-maven-plugin:1.0.8:invoke' with basic configurator -->
[DEBUG] (f) gradleProjectDirectory = /Users/pmandala/ORAHUB/spark-cloud-service/bdcsce-dist
[DEBUG] (f) gradleVersion = 2.13
[DEBUG] (f) mavenBaseDir = /Users/pmandala/ORAHUB/spark-cloud-service/bdcsce-dist
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@79e18e38
[DEBUG] (f) tasks = [hello]
[DEBUG] -- end configuration --
[INFO] jvmArgs: null
[INFO] gradleProjectDirectory: /Users/pmandala/ORAHUB/spark-cloud-service/bdcsce-dist
[DEBUG] Connecting from tooling API consumer version 2.13
[INFO] Build
Downloading https://services.gradle.org/distributions/gradle-2.13-bin.zip
[INFO] Download https://services.gradle.org/distributions/gradle-2.13-bin.zip
[DEBUG] waiting....
[DEBUG] waiting....
[DEBUG] waiting....
[DEBUG] waiting....
[INFO] Build
[INFO]
[DEBUG] waiting....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:16 min
[INFO] Finished at: 2016-12-22T14:29:14-08:00
[INFO] Final Memory: 10M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.8:invoke (default) on project bdcsce-dist: org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.13-bin.zip'. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.8:invoke (default) on project bdcsce-dist: org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.13-bin.zip'.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.13-bin.zip'.
at org.fortasoft.maven.plugin.gradle.GradleMojo.execute(GradleMojo.java:270)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Sample plugin invocation:
<plugin>
<groupId>org.fortasoft</groupId>
<artifactId>gradle-maven-plugin</artifactId>
<version>1.0.5</version>
<configuration>
<tasks>
<!-- this would effectively call "gradle doSomething" -->
<task>build</task>
</tasks>
<gradleVersion>2.2.1</gradleVersion>
<gradleProjectDirectory>../gradletest</gradleProjectDirectory>
</configuration>
<executions>
<execution>
<!-- You can bind this to any phase you like -->
<phase>compile</phase>
<goals>
<!-- goal must be "invoke" -->
<goal>invoke</goal>
</goals>
</execution>
</executions>
</plugin>
[ERROR] Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.5:invoke (default) on project gradlebridge: Execution default of goal org.fortasoft:gradle-maven-plugin:1.0.5:invoke failed: A required class was missing while executing org.fortasoft:gradle-maven-plugin:1.0.5:invoke: org/slf4j/impl/NewMojoLogger
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.fortasoft:gradle-maven-plugin:1.0.5
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/donald/.m2/repository/org/fortasoft/gradle-maven-plugin/1.0.5/gradle-maven-plugin-1.0.5.jar
[ERROR] urls[1] = file:/Users/donald/.m2/repository/org/gradle/gradle-tooling-api/1.6/gradle-tooling-api-1.6.jar
[ERROR] urls[2] = file:/Users/donald/.m2/repository/org/codehaus/groovy/groovy-all/2.0.6/groovy-all-2.0.6.jar
[ERROR] urls[3] = file:/Users/donald/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :gradlebridge
Cobalt:scratch donald$
I've been taking advantage of the the checkInvokeScript configuration setting built into this mojo to ensure that this plugin only gets execute once in a multi-module build. My solution was working fine until some windows developers tried to build my project. The issue that we ran into is that my checkInvoke script looks something like this:
<groupId>org.fortasoft</groupId>
<artifactId>gradle-maven-plugin</artifactId>
<version>1.0.7</version>
<executions>
<execution>
<id>build application configuration</id>
<phase>process-resources</phase>
<goals>
<goal>invoke</goal>
</goals>
<configuration>
<!--
this script is called by the gradle-maven-plugin
to determine if gradle build should be invoked.
Our script keeps a timestamp file based on the
maven session starttime. We will only execute
the gradle build once per session. This is useful
where multiple project within a build need to share
configuration. We only need to set it up once
-->
<checkInvokeScript>
def ts = "$${session.startTime.time}"
def buildDir = new File("$gradleBuildDir'}")
buildDir.mkdirs()
def markerFile = new File("$gradleBuildDir'}/gradleTimestamp.txt")
if (!markerFile.exists() || !markerFile.text.equals(ts)) {
markerFile.text = ts
return true
} else {
println "Gradle already run this maven session. Skipping"
return false
}
</checkInvokeScript>
In this case gradleBuildDir is a maven property I make sure is always set to a correct directory. During maven execution time, maven will interpolate that properties prior to your mojo executing the groovy script.
The problem I'm running into is that for windows users, the directory might have a backslash character in it, like this c:\path\to\file
And this causes errors like this when the plugin executes:
[ERROR] Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.5:invoke (build application configuration) on project key-mgmt: Execution build application configuration of goal org.fortasoft:gradle-maven-plugin:1.0.5:invoke failed: startup failed:
[ERROR] Script1.groovy: 1: unexpected char: '\' @ line 1, column 21.
To work around this, in a fork, I modified the mojo to bind the MavenProject and MavenSession instances to variables available when executing the script, like such:
protected boolean shouldExecute() throws MojoFailureException {
boolean shouldExecute = true;
if (checkInvokeScript != null && checkInvokeScript.trim().length() > 0) {
Binding b = new Binding();
b.setVariable("mavenBaseDir", mavenBaseDir);
b.setVariable("session", session);
b.setVariable("project", project);
Then the script can look like this:
<checkInvokeScript>
def ts = "$${session.startTime.time}"
def buildDir = new File("$${project.properties['gradleBuildDir']}")
buildDir.mkdirs()
def markerFile = new File("$${project.properties['gradleBuildDir']}/gradleTimestamp.txt")
if (!markerFile.exists() || !markerFile.text.equals(ts)) {
markerFile.text = ts
return true
} else {
println "Gradle already run this maven session. Skipping"
return false
}
</checkInvokeScript>
This seems to solve my problem nicely.
I will followup with a merge request from my fork that I hope you will consider accepting and merging removing the need for me to maintain my fork.
Thanks so much for this helpful plugin.
Doug
Multi thread build failed sometimes due to gradle plugin racing for downloaded distribution 'https://services.gradle.org/distributions/gradle-7.1.1-bin.zip' on fresh environment
I suggest synchronizing the gradle init method to avoid such an issue
mvn clean install -DskipTests -T6
[ERROR] Failed to execute goal org.thingsboard:gradle-maven-plugin:1.0.11:invoke (default) on project http: org.gradle.tooling.GradleConnectionException: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-7.1.1-bin.zip'. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf org.thingsboard.transport:http
The last release of this plugin was 1.0.5 and there has been a good number of changes to the master since that time, including a fix I need which you had kindly merged some time ago.
Perhaps before releasing you would consider merging pull request #20 as well, as this will also prove useful to me.
Thanks in advance.
In version 2.6, the tooling API added another withArguments() method to BuildLauncher (actually the superclass, ConfigurableLauncher) which seems to interfere with the plugin's call to this method. The GradleMojo's call to withArguments() (happens here: https://github.com/if6was9/gradle-maven-plugin/blob/master/src/main/java/org/fortasoft/maven/plugin/gradle/GradleMojo.java#L240) results in a NoSuchMethodError if you use any tooling API version above 2.5.
Starting gradle can take a few seconds, even if the execution of the gradle tasks ends up being a no-op.
Provide the ability to pass an expression or script to the gradle-maven-plugin that would let it forego any execution at all.
Is there any property for setting custom build file name such as _build.gradle
?
Not sure if this is an actual bug or just me not understanding what my configuration should be to do so.
Regardless, when I run mvn package
with the plugin, it generates some APKs for my Android app, but they are still there after running mvn clean
.
This is a great plugin. Thanks for developing it. One enhancement request would be to add provisions in the configuration to support the following:
1. specify which version of gradle to use ( right now it defaults 1.3)
2.. specify a URL for the distribution of gradle to use (in case there is a custom build distribution for a given organization)
3. specify a home directory for gradle to run out of.
The functionality is available in the tooling api, so this should be relatively easy to accommodate. Since you're on github I could potentially take a stab at forking the code and trying it out and submitting a pull request.
Thanks.
Doug
This plugin does not work with the latest gradle versions beyond 5.0. For example, with 5.1.1:
org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-5.1.1-bin.zip'
This is a bit of a misleading exception, the reality is this plugin does not support the new tooling API. If I build against 4.10.1, I get this message in the output:
Support for clients using a tooling API version older than 3.0 was deprecated and will be removed in Gradle 5.0. You are currently using tooling API version 2.13. You should upgrade your tooling API client to version 3.0 or later.
Is there a plan to support the new tooling API?
Fine on openjdk7 and oraclejdk6/7
This appears to be a recreation of #15 but with Maven 3.3.3.
My pom.xml is in the same directory as build.gradle. My pom looks like the following:
<?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>io.sample</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>sample</artifactId>
<packaging>pom</packaging>
<name>Sample</name>
<build>
<plugins>
<plugin>
<groupId>org.fortasoft</groupId>
<artifactId>gradle-maven-plugin</artifactId>
<version>1.0.5</version>
<configuration>
<tasks>
<!-- this would effectively call "gradle doSomething" -->
<task>build</task>
</tasks>
</configuration>
<executions>
<execution>
<!-- You can bind this to any phase you like -->
<phase>compile</phase>
<goals>
<!-- goal must be "invoke" -->
<goal>invoke</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Output from running mvn compile
and mvn -version
:
» mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Sample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- gradle-maven-plugin:1.0.5:invoke (default) @ android-sample ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.303 s
[INFO] Finished at: 2015-07-08T10:06:15-04:00
[INFO] Final Memory: 6M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.5:invoke (default) on project android-sample: Execution default of goal org.fortasoft:gradle-maven-plugin:1.0.5:invoke failed: A required class was missing while executing org.fortasoft:gradle-maven-plugin:1.0.5:invoke: org/slf4j/impl/NewMojoLogger
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.fortasoft:gradle-maven-plugin:1.0.5
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/whaley/.m2/repository/org/fortasoft/gradle-maven-plugin/1.0.5/gradle-maven-plugin-1.0.5.jar
[ERROR] urls[1] = file:/Users/whaley/.m2/repository/org/gradle/gradle-tooling-api/1.6/gradle-tooling-api-1.6.jar
[ERROR] urls[2] = file:/Users/whaley/.m2/repository/org/codehaus/groovy/groovy-all/2.0.6/groovy-all-2.0.6.jar
[ERROR] urls[3] = file:/Users/whaley/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
» mvn --version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T07:57:37-04:00)
Maven home: /usr/local/Cellar/maven/3.3.3/libexec
Java version: 1.8.0_31, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.4", arch: "x86_64", family: "mac"
i have tried several configurations to disable the gradle daemon, but none seems to work.
<args><arg>-Dgradle.prop.org.gradle.daemon=false</arg></args>
<jvmArgs><jvmArg>-Dgradle.prop.org.gradle.daemon=false</jvmArg></jvmArgs>
set gradle user home to a custom location and added a gradle.properties with the value "org.gradle.daemon=false"
added command line setting "mvn -Dorg.gradle.daemon=false -Dgradle.prop.org.gradle.daemon=false"
none of the options are working.. am i missing something?
note: i am using gradle 2.3, cannot upgrade due to some other constraints
Requiring a custom artifact repository can be a hassle. Would be nice to just get it from central so that extra step isn't required.
mvn integration-test
fails when building with Maven 3.3.1.
From target/it/check-invoke-it/build.log
:
[ERROR] Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.6-SNAPSHOT:invoke (default) on project check-invoke-it: The parameters 'gradleVersion' for goal org.fortasoft:gradle-maven-plugin:1.0.6-SNAPSHOT:invoke are missing or invalid -> [Help 1]
and target/it/main-it/build.log
:
[ERROR] Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.6-SNAPSHOT:invoke (default) on project gradle-maven-plugin-test: The parameters 'gradleVersion' for goal org.fortasoft:gradle-maven-plugin:1.0.6-SNAPSHOT:invoke are missing or invalid -> [Help 1]
This is with
$ mvn -version
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T21:10:27+01:00)
Maven home: /usr/local/Cellar/maven/3.3.1/libexec
Java version: 1.7.0_11, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"
Running /usr/share/java/maven-3.0.4/bin/mvn integration-test
(OSX 10.8 vanilla Maven) works fine.
So basically, someone can just include this plugin in his maven build, and then gradlew or gradlew.bat from the project directory would be used, to benefit from all the gradle goodness, i.e. not having to install anything else ;)
I'm trying to start two tasks of gradle in two different maven phases. It is even possible?
I want to add my custom changelog in deb
file. How can I do it? Currently it does not add any changelog.
Both the default gradle version and gradle-tooling-api should be moved to 1.7
In the case where someone runs mvn on the command line with --offline option, it would be convenient for the gradle plugin to detect the fact that offline mode is enabled and then automatically include "--offline" in the argument list for invoking gradle. This way we don't have to come up with our mechanism for telling both mvn and gradle to be offline. Developers use to mvn will tend to only remember the mvn --offline option.
Thanks.
1.0.5 is latest. Please help to make it available new every new release
[ERROR] Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.8:invoke (default) on project connected: Execution default of goal org.fortasoft:gradle-maven-plugin:1.0.8:invoke failed: Could not determine java version from '9.0.1'. -> [Help 1]
intellij eap latest, maven bundled 3.3.9,
RELEASE jdk9
The Gradle distribution is downloaded over unencrypted http, leaving the installation of Gradle itself open to man-in-the-middle attacks.
Moreover, even if gradleVersion
is set to a version for which the Gradle wrapper was already installed externally (and through https), this plugin seems to download it again – via http!
It turns out that these issues can be solved by upgrading the gradle-tooling-api
dependency from 1.7 (which dates from 2012!) to at least 1.12. But since the default Gradle version installed is already 2.4 (a bit behind the current one, 2.11, but whatever), perhaps the Tooling API dependency could be updated to at least that same version?
I have a multi-module maven project, and my gradle project has a dependency on a maven project within the same build. The problem I have is that the Maven reactor will not provide the maven artifacts to the gradle project unless the install
goal is run. This creates a problem for our feature builds, as we don't wish to install the artifacts as they would impact other builds using the same build system. Is there anyway gradle could resolve these dependent maven artifacts without requiring them to be installed in a local repository?
When I used this plugin in my project's pom, it seems to be using gradle version 1.6.
Is there a way for me to enforce this to use the gradle version 2.2.1?
How can I use gradle wrapper to execute tasks?
[INFO] --- gradle-maven-plugin:1.0.5:invoke (default) @ twigkit-gsa ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.228 s
[INFO] Finished at: 2015-11-02T11:44:54+01:00
[INFO] Final Memory: 22M/331M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.5:invoke (default) on project twigkit-gsa: Execution default of goal org.fortasoft:gradle-maven-plugin:1.0.5:invoke failed: A required class was missing while executing org.fortasoft:gradle-maven-plugin:1.0.5:invoke: org/slf4j/impl/NewMojoLogger
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.fortasoft:gradle-maven-plugin:1.0.5
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/schlei/.m2/repository/org/fortasoft/gradle-maven-plugin/1.0.5/gradle-maven-plugin-1.0.5.jar
[ERROR] urls[1] = file:/home/schlei/.m2/repository/org/gradle/gradle-tooling-api/1.6/gradle-tooling-api-1.6.jar
[ERROR] urls[2] = file:/home/schlei/.m2/repository/org/codehaus/groovy/groovy-all/2.0.6/groovy-all-2.0.6.jar
[ERROR] urls[3] = file:/home/schlei/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[project>twigkit:twigkit-gsa:2.10.6, parent: ClassRealm[maven.api, parent: null]]]
[ERROR]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.