Gradle: Error listing versions of junit#junit;4.+ - junit

I am getting the below error when running gradle build on my gradle.properties file.
I know I am behind a firewall and I have a poxy I can use. I've tried adding the below to my gradle.properties file, but I cannot pull down jUnit. All help appreciated!
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
Error:
Error listing versions of junit#junit;4.+ using class
org.gradle.api.internal.artifacts.repositories.resolver.MavenVersionLister$1.
Will attempt an alternate way to list versions. This behaviour has been
deprecated and is scheduled to be removed in Gradle 2.0
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':testRuntime'.
> Could not resolve junit:junit:4.+.
Required by:
:HealthMonitor:1.0
> Failed to list versions for junit#junit;4.+.
> Could not list versions using M2 pattern 'http://repo1.maven.org/maven2/
[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'.
> Could not GET 'http://repo1.maven.org/maven2/junit/junit/'.
> Connection to http://repo1.maven.org refused
build.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Health Monitor', 'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
}

Depending on the proxy, you may have to configure more than just the host and port. See Accessing the web via a proxy in the Gradle User Guide. Also, I recommend to try with a fixed version rather than a version range.

Related

spring boot with gradle not starting up

I am trying to build sample hello application using gradle build in Spring tool suite facing below design time error.
I have grade version 4.10.2 installed on my machine.
Error Msg:
Description Resource Path Location Type
Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.10.2-bin.zip'.
Build file 'C:\TFS\Study\Springboot\GradleExamples\workspace\Gradle_Hello\build.gradle' line: 14
Plugin [id: 'org.springframework.boot', version: '2.1.2.RELEASE'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.1.2.RELEASE')
Searched in the following repositories:
Gradle Central Plugin Repository
Plugin [id: 'org.springframework.boot', version: '2.1.2.RELEASE'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.1.2.RELEASE')
Searched in the following repositories:
Gradle Central Plugin Repository build.gradle /Gradle_Hello line 14 Gradle Error Marker
Next time, please include your build.gradle file.
I believe your problem is caused by the fact you are trying to apply the plugin:'org.springframework.boot' without telling your gradle script where to find that plugin. Your buildscript (build.gradle file) actually depends on the org.springframework.boot plugin, however since it can't find it (and doesn't even know what it is), you are getting this issue.
you can fix that issue by adding the following code at the top of your file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
// You are telling gradle that this script (Not the project) depends on the
// following plugin
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.2.RELEASE"
}
}
apply plugin: "org.springframework.boot"
// The rest of your build.gradle file
I had the same problem, so I changed to Gradle 6.5 and also add settings.gradle file in the same dir as your build.gradle with the following info.
// settings.gradle
pluginManagement {
plugins {
id "org.springframework.cloud.contract" version "${verifierVersion}"
}
repositories {
// to pick from local .m2
mavenLocal()
// for snapshots
maven { url "https://repo.spring.io/snapshot" }
// for milestones
maven { url "https://repo.spring.io/milestone" }
// for GA versions
gradlePluginPortal()
}
}
In addition make sure that you can connect to your repositories. In my case if was a internal nexus server and gradle wasn't able to connect to the repositories because of SSL certificate missing from JDK truststore. I added the nexus SSL certificate in to the JDK truststore and it resolved

Topology not working due to Found multiple defaults.yaml resources when deploying to remote cluster

I have a single node remote cluster set up (all nimbus , supervisor , zookeeper) running on the same machine . I deployed my Topology (simple Exclamation Topology) to this remote cluster . While topology and jar got submitted successfully , nothing is happening in the cluster .
When I checked the supervisor logs , I could see this :
2015-10-14T21:24:26.340+0000 b.s.d.supervisor [INFO] 42dd0337-1182-45b0-9385-14570c7e0b09 still hasn't started
Worker log files are empty .
On debugging a little in supervisor logs , I could see
Launching worker with command: (Some java command) ..Firing this java command I can see this error :
Caused by: java.lang.RuntimeException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar.
I debugged more on internet and other stuff , and modified my build.gradle file too but still the same error whenever I deploy my topology .
This is my gradle file
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: springBootVersion
compile group: 'org.quartz-scheduler', name: 'quartz', version: quartzVersion
compile group: 'clj-stacktrace' , name: 'clj-stacktrace',version: cljStackTrace
compile group: 'org.apache.storm' , name: 'storm-core',version: stormVersion
ext {
fatJarExclude = true
}
}
task uberjar(type: Jar) {
from files(sourceSets.main.output.classesDir)
from {configurations.compile.collect {zipTree(it)}} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
exclude "META-INF/LICENSE"
}
manifest {
attributes 'Main-Class': 'storm.topology.ExclamationTopology'
}
}
The jar file must not contain defaults.yaml file. Thus, you need to exclude it via
exclude "defaults.yaml"
Actually I would recommend the exclude all Storm dependencies from your jar. They are not needed and increase the size of the fat jar unnecessarily.
When packaging your topology jar, don't include the Storm jars as Storm will put those on the classpath for you.
Reference
http://storm.apache.org/releases/1.0.2/Troubleshooting.html
There are two options:
1- Delete using winrar "defaults.yaml" in the .jar
2- adding in the pom.xml storm-core as provided.
In my pom.xml:
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>0.9.1-incubating</version>
<scope>provided</scope>
</dependency>

Viewing results of junit test for gradle?

So I currently have the following build.gradle file:
apply plugin: 'java'
sourceSets {
main {
java {
srcDir 'src/model'
}
}
test {
srcDirs = ["tests/model"]
}
}
dependencies {
compile files('libs/mnist-tools.jar', 'libs/gson-2.2.4.jar')
runtime fileTree(dir: 'libs', include: '*.jar')
testCompile group: 'junit', name: 'junit', version: '4.+'
}
that builds successfully when I type "gradle test" into the command line.
However I do the following error when running gradle test:
Creating properties on demand(a.k.a dynamic properties) has been deprecated.
As you can see, my junit tests are all in the folder test/model/ but I was wondering how do I see the results of if my junit tests passed?
You can view my repository here: https://github.com/quinnliu/WalnutiQ
Chingy,
I had to update a couple of things in your build.gradle:
source set for tests
added Maven repository to get JUnit library
apply plugin: 'java'
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDir 'src/model'
}
}
test {
java {
srcDir 'tests/model'
}
}
}
dependencies {
compile files('libs/mnist-tools.jar', 'libs/gson-2.2.4.jar')
runtime fileTree(dir: 'libs', include: '*.jar')
testCompile group: 'junit', name: 'junit', version: '4.+'
}
Now, the results of $ gradle build:
bender:WalnutiQ demo$ gradle build
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processTestResources UP-TO-DATE
:testClasses
:test
model.RetinaTest > test_seeBMPImage FAILED
java.lang.IllegalArgumentException at RetinaTest.java:25
model.MARK_I.SpatialPoolerTest > test_performSpatialPoolingOnRegion FAILED
java.lang.IllegalArgumentException at SpatialPoolerTest.java:60
model.util.JsonFileInputOutputTest > test_saveRegionObject FAILED
java.lang.IllegalArgumentException at JsonFileInputOutputTest.java:69
model.util.SynapsePermanencesViewerTest > test_saveRegionToBeOpenedInSynapsePermanencesViewer FAILED
java.lang.IllegalArgumentException at SynapsePermanencesViewerTest.java:45
49 tests completed, 4 failed
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///Users/demo/development/tmp/WalnutiQ/build/reports/tests/index.html
I think you can take it from here :o)
PS: I would recommend to refactor your project structure to match Maven/Gradle structure, so you don't have to deal with source sets and it will make your build.gradle cleaner.
src/main/java Production Java source
src/main/resources Production resources
src/test/java Test Java source
src/test/resources Test resources
src/sourceSet/java Java source for the given source set
src/sourceSet/resources Resources for the given source set
When you run gradle build or gradle test, there is a build directory that is created.
This directory is where all the build artifacts are placed.
Inside the build directory is a reports directory. This directory is where reports are placed.
For example, pmd reports, junit reports, etc.
The JUnit reports are located in the tests directory. Open up the index.html file in a browser to view the report.
You can specify where the JUnit test results go with the following command within your test block.
test {
reports.junitXml.destination = file('build/test-results/folder')
}

simple gradle build running compass failing

I have a very simple gradle project. I am just trying to run compass. However when I do try to run gradle installCompass the build fails. I included the build script I am using. I only have this script and a single scss file in the project.
build.gradle
apply plugin: 'compass'
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url 'http://dl.bintray.com/robfletcher/gradle-plugins' }
}
dependencies {
classpath 'org.jruby:jruby-complete:1.7.3'
classpath 'org.gradle.plugins:gradle-compass:1.0.7'
}
}
compass {
cssDir = file('public/styles')
sassDir = file('scss')
}
the error I get
A problem occurred configuring root project 'GradleStyleGuide'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find org.jruby:jruby-complete:1.7.3..
Required by:
:GradleStyleGuide:unspecified
this is the result of a dependency check
compass
\--- org.jruby:jruby-complete:1.7.3 FAILED
Here is what happens when I run the build from command line.
Gradle 1.6
------------------------------------------------------------
Gradle build time: Tuesday, May 7, 2013 9:12:14 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_17 (Oracle Corporation 23.7-b01)
OS: Windows 7 6.1 amd64
C:\Users\me>cd \code\GradleStyleGuide
C:\code\GradleStyleGuide>gradle installCompass
Download http://repo1.maven.org/maven2/org/jruby/jruby-complete/1.7.3/jruby-complete-1.7.3.pom
Download http://repo1.maven.org/maven2/org/jruby/shared/1.7.3/shared-1.7.3.pom
Download http://dl.bintray.com/robfletcher/gradle-plugins/org/gradle/plugins/gradle-compass/1.0.7/gradle-compass-1.0.7.pom
Download http://repo1.maven.org/maven2/org/jruby/jruby-complete/1.7.3/jruby-complete-1.7.3.jar
Download http://dl.bintray.com/robfletcher/gradle-plugins/org/gradle/plugins/gradle-compass/1.0.7/gradle-compass-1.0.7.jar
:installCompass FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':installCompass'.
> Could not resolve all dependencies for configuration ':compass'.
> Could not find org.jruby:jruby-complete:1.7.3.
Required by:
:GradleStyleGuide:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 10.014 secs
I can resolve jruby-complete just fine (using your build script). Chances are that the problem is related to your environment (e.g. no proxy settings configured for Gradle). I recommend to run with --info and check the log output.
After adding a wrapper task and a repository of mavenCentral, outside of buildscript I was able to get this to work.
buildscript {
repositories {
mavenCentral()
maven { url 'http://dl.bintray.com/robfletcher/gradle-plugins' }
}
dependencies {
classpath 'org.gradle.plugins:gradle-compass:1.0.7'
}
}
repositories {
mavenCentral()
}
apply plugin: 'compass'
task wrapper(type: Wrapper) {
gradleVersion = "1.6"
}
compass {
cssDir = file('public/styles')
sassDir = file('sass')
}

How to configure UglifyJS with Gradle?

Are there any ready-to-use Gradle plugins to use for UglifyJs? We are trying to configure Uglify something similar to what has been done here, but the owner of that project seems to have his own private artifactory to which he points to, thereby getting access to UglifyAntTask, which is a github-hosted project not following Gradle/Maven etc. (basically non-managed) JAR. We tried downloading this JAR to our project and tried configuring using the options suggested in gradle page as follows:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar') (or)
compile files('uglifyjs-java-v1.0.jar')
}
Note: The (or) is not there in actual code, I mentioned only to indicate that we tried both options but it was not picking the JAR.
So at a later step, when we gave
ant.taskdef(name: "uglify", classname: "uglify.ant.UglifyTask", classpath: configurations.uglifyjs.asPath)
Gradle throws the following errror:
taskdef class uglify.ant.UglifyTask cannot be found
using the classloader AntClassLoader[]
I am hoping that at least some one must have had the need to include non-managed 3rd party JAR and have figured out how to do this, if so, please point the solution/mistake we have made.
Thanks,
Paddy
Here is how the offical Gradle documentation describe it:
configurations {
uglifyjs
}
dependencies {
uglifyjs files('uglifyjs-java-v1.0.jar')
}
task uglifyjs << {
ant.taskdef(name: 'uglifyjs', classname: 'uglify.ant.UglifyTask', classpath: configurations.uglifyjs.asPath)
ant.uglifyjs( ... UglifyJS Ant Task parameters ... )
}
See http://www.gradle.org/docs/current/userguide/ant.html#N11416
HTH