In my build.gradle, I'm defining 2 different flavor dimensions:
//list flavorDimensions in override priority order
flavorDimensions 'flavor', 'platform'
//assign each productFlavor a corresponding flavorDimension
productFlavors {
flavor1 {
dimension 'flavor'
applicationId "com.flavor1"
}
flavor2 {
dimension 'flavor'
applicationId "com.flavor2"
}
mobile {
dimension 'platform'
applicationIdSuffix '.mobile'
minSdkVersion 22
}
tv {
dimension 'platform'
applicationIdSuffix '.tv'
minSdkVersion 21
}
}
I would like to be able to set versionCode and versionName based on the combinations, so each of the following could have it's own version info:
flavor1Mobile
versionName = 1.0.0
versionCode = 3
flavor1Tv
versionName = 1.0.2
versionCode = 5
flavor2Mobile
versionName = 3.0.0
versionCode = 10
flavor2Tv
versionName = 2.0.0
versionCode = 4
Was able to build a solution by combining the solutions from :
https://stackoverflow.com/a/30880966
https://developer.android.com/studio/build/gradle-tips#configure-dynamic-version-codes
project.ext{
flavor1Mobile_versionName = "1.0.0"
flavor1Mobile_versionCode = 3
flavor1Tv_versionName = "1.0.2"
flavor1Tv_versionCode = 5
flavor2Mobile_versionName = "3.0.0"
flavor2Mobile_versionCode = 10
flavor2Tv_versionName = "2.0.0"
flavor2Tv_versionCode = 4
}
project.android.applicationVariants.all {variant ->
def versionName = project.ext."${variant.flavorName}_versionName"
def versionCode = project.ext."${variant.flavorName}_versionCode"
variant.outputs.each { output ->
output.versionNameOverride = versionName
output.versionCodeOverride = versionCode
}
}
I've got the same problem and was able to solve it a little bit different, but depending on the circumstances of future visitors of this page, it may help.
In your global gradle.properties file you can define your different versions:
flavor1_versionName=1.0.0
flavor2_versionName=1.2.3
mobile_versionName=1.0.1
tv_versionName=1.0.2
Then you can just override the versionName parameter in your build.gradle(:app) file where you add your productFlavors:
productFlavors {
flavor1 {
dimension 'flavor'
applicationId "com.flavor1"
versionName = flavor1_versionName;
}
flavor2 {
dimension 'flavor'
applicationId "com.flavor2"
versionName = flavor2_versionName;
}
mobile {
dimension 'platform'
applicationIdSuffix '.mobile'
minSdkVersion 22
versionName = mobile_versionName;
}
tv {
dimension 'platform'
applicationIdSuffix '.tv'
minSdkVersion 21
versionName = tv_versionName;
}
}
In your defaultConfig block in the same build.gradle file, you can say:
versionName version
project.version version
Related
I'm using jpackage to convert the jar file to an exe, with the exe file provided by the internal JRE. As a result of the conversion, good results were obtained, the JRE weighs about 38.5 mb.
When I run the exe, the GUI quality is twice as WORSE as in a normal jar! In addition, the window of the new exe file increases on its own. Thus, very strange changes appear, as if the exe file is trying to imitate a window jar file. I want to point out that I am using libGdx for the GUI.
desktop gradle:
{
plugins { id 'org.beryx.runtime' version '1.8.4' }
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = ["src/"]
sourceSets.main.resources.srcDirs = ["../android/assets"]
mainClassName = "com.iapp.chess.desktop.DesktopLauncher"
def osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
project.ext.assetsDir = new File("../android/assets")
task runGame(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
destinationDirectory = file("$buildDir/lib")
}
jpackageImage.dependsOn dist
dist.dependsOn classes
eclipse.project.name = appName + "-desktop"
runtime {
options = ['--strip-debug',
'--compress', '2',
'--no-header-files',
'--no-man-pages',
'--strip-native-commands',
'--vm', 'server']
modules = ['java.base',
'java.desktop',
'jdk.unsupported']
distDir = file(buildDir)
jpackage {
jpackageHome = 'C:\\Program Files\\Java\\jdk-17.0.2'
mainJar = dist.archiveFileName.get()
if (osName.contains('windows')) {
imageOptions = ["--icon", file("../icons/icon.ico")]
} else if (osName.contains('linux')) {
imageOptions = ["--icon", file("../icons/icon.png")]
} else if (osName.contains('mac')) {
imageOptions = ["--icon", file("../icons/icon.icns")]
}
}
}
}
I am trying to build libGDX project for Android via Gradle.
I get following error: Could not find org.jetbrains.trove4j: trove4j: 20160824.
I have tried every combination of:
jCenter(), mavenLocal(), mavenCentral(), google()
In my build.gradle files, root and android's one.
Also tried different orders of it, as suggested by others in other forums.
What sould I do?
Full error:
Could not resolve all files for configuration ':android:debugCompileClasspath'.
> Could not find org.jetbrains.trove4j:trove4j:20160824.
Searched in the following locations:
- file:/media/mruser/Data/AndroidSDK/extras/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- file:/media/mruser/Data/AndroidSDK/extras/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- file:/media/mruser/Data/AndroidSDK/extras/google/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- file:/media/mruser/Data/AndroidSDK/extras/google/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- file:/media/mruser/Data/AndroidSDK/extras/android/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- file:/media/mruser/Data/AndroidSDK/extras/android/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- file:/home/mruser/.m2/repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- file:/home/mruser/.m2/repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- https://oss.sonatype.org/content/repositories/snapshots/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- https://oss.sonatype.org/content/repositories/snapshots/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- https://oss.sonatype.org/content/repositories/releases/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- https://oss.sonatype.org/content/repositories/releases/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- file:/home/mruser/GDX/ColorGame/libs/trove4j-20160824.jar
- file:/home/mruser/GDX/ColorGame/libs/trove4j.jar
Required by:
project :android
Root build.gradle:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.3'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "ColorfulGame"
gdxVersion = '1.9.8'
roboVMVersion = '2.3.3'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
flatDir {
dir rootProject.file( 'libs' )
}
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:design:23.1.1'
compile group: 'org.jetbrains.trove4j', name: 'trove4j', version: '20160824'
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile files("libs/SGDX.jar")
}
}
tasks.eclipse.doLast {
delete ".project"
}
Android build.gradle:
android {
buildToolsVersion "28.0.3"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'
}
defaultConfig {
applicationId "sk.ap.cg"
minSdkVersion 9
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if(outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'sk.ap.cg/sk.ap.cg.AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}
jdt {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
classpath {
plusConfigurations += [ project.configurations.compile ]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}
project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [ COMPILE: [plus:[project.configurations.compile]]]
iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value:"true")
}
}
}
}
}
}
}
Problem was asociated with mavenCentral() and mavenLocal().
allproject and buildfile closures in root buildfile should look like this:
repositories {
jcenter()
google()
}
If someone still looks for solution and mavens are ok - in my case problem was with outdated react-native-document-picker library. I installed last version and problem has gone. So be sure problem is not caused by your libraries.
I am trying to check if map centre is inside a polygon or not. My code for creating mulitple polygons on map is this:
for (int i = 0; i < Constant.arr_zone.size(); i++) {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
ArrayList<LatLng> list = new ArrayList<>();
for (int j = 0; j < Constant.arr_zone.get(i).polygon.length; j++) {
list.add(new LatLng(Constant.arr_zone.get(i).polygon[j].geo_x,
Constant.arr_zone.get(i).polygon[j].geo_y));
builder.include(list.get(j));
}
polygonOptions = new PolygonOptions();
polygonOptions.addAll(list);
polygonOptions.strokeColor(R.color.theme_color);
polygonOptions.strokeWidth(2);
polygonOptions.fillColor(Color.parseColor("#33000040"));
Polygon polygon = mMap.addPolygon(polygonOptions);
ltbounds = builder.build();
arr_ltlngbounds.add(ltbounds);
}
Next I am checking if map center is inside any polygon or not
map.setOnCameraChangeListener(new OnCameraChangeListener() {
#Override
public void onCameraChange(CameraPosition cameraPosition) {
if (arr_ltlngbounds != null && arr_ltlngbounds.size() > 0) {
for (LatLngBounds l : arr_ltlngbounds) {
if (l.contains(mMap.getCameraPosition().target)) {
snackbar = Snackbar
.make(inflatedView, "Service available here", Snackbar.LENGTH_INDEFINITE)
.setAction("GET", new View.OnClickListener() {
#Override
public void onClick(View view) {
String arr[] = {user_location.latitude + "", user_location.longitude + "", "4"};
new Get_service(activity, A.this, get_service).execute(arr);
}
});
snackbar.show();
break;
}
}
}
}
});
This is my build.gradle just incase
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
multiDexEnabled true
applicationId "com.aaa.bbb"
minSdkVersion 14
targetSdkVersion 23
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile project(':library')
compile 'com.android.support:appcompat-v7:23.1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.newrelic.agent.android:android-agent:5.3.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.github.jaydeepw:poly-picker:v1.0.22'
compile 'com.xgc1986.android:parallaxpagertransformer:1.0.3'
compile 'com.google.code.gson:gson:2.6.2'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
compile 'com.github.castorflex.smoothprogressbar:library:1.0.0'
compile 'com.github.clans:fab:1.6.2'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
compile('com.google.api-client:google-api-client-android:1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-drive:v3-rev6-1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.newrelic.agent.android:agent-gradle-plugin:5.3.1"
}
}
repositories {
mavenCentral()
// for downloading polypicker dependency cwac-camera
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
// for downloading poly-picker now we are using jitpack.
// Goodbye Maven Central
maven {
url "https://jitpack.io"
}
}
apply plugin: 'android'
apply plugin: 'newrelic'
dependencies {
compile 'com.android.support:support-v4:22.2.1'
}
android {
useLibrary 'org.apache.http.legacy'
}
The problem about this implementation is, it still shows snackbar (that latlng is inside bounds) even if latlng is outside bounds up to a certain level like there is some buffer area where it will still detect the latlng. I want it to be precise. How can I rectify this?
You can use the PolyUtil.containsLocation method from the Google Maps Android API Utility Library to check if a given location lies inside a polygon represented by a List<LatLng> instead of just checking if the location is in the boundary.
Example:
// Construct a List<LatLng> representing a Polygon
List<LatLng> polygon = new ArrayList<>();
polygon.add(new LatLng(3,0));
polygon.add(new LatLng(3,3));
polygon.add(new LatLng(0,3));
polygon.add(new LatLng(3,0));
// Find the LatLngBounds of the Polygon
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (LatLng point : polygon) {
builder.include(point);
}
LatLng test = new LatLng(1,1);
boolean isInsideBoundary = builder.build().contains(test); // true as the test point is inside the boundary
boolean isInside = PolyUtil.containsLocation(test, polygon, true); // false as the test point is outside the polygon
I'm using eclipse and Grails 2.5.1 with MySQL DB with driver version 5.1.36 and it is working fine in the Run mode , but when i try to use the debug mode i get the below error :
context.GrailsContextLoaderListener , Error initializing the
application: No suitable driver found for
jdbc:mysql://127.0.0.1/MY_Dev
here is the BuildConfig :
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.29'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
runtime 'mysql:mysql-connector-java:5.1.36'
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55.3" // or ":tomcat:8.0.22"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
// asset-pipeline 2.0+ requires Java 7, use version 1.9.x with Java 6
compile ":asset-pipeline:2.2.3"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.10" // or ":hibernate:3.6.10.18"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
//security plugin
compile ':spring-security-core:2.0-RC5'
compile ":spring-security-ui:1.0-RC2"
compile ":mail:1.0.7"
compile ":jquery-ui:1.10.4"
compile ":famfamfam:1.0.1"
//internal mails plugin
compile ":grails-direct-messages:1.0"
// Uncomment these to enable additional asset-pipeline capabilities
//compile ":sass-asset-pipeline:1.9.0"
//compile ":less-asset-pipeline:1.10.0"
//compile ":coffee-asset-pipeline:1.8.0"
//compile ":handlebars-asset-pipeline:1.3.0.3"
}
}
and here is the DataSource:
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'org.hibernate.cache.SingletonEhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}
// environment specific settings
environments {
development {
dataSource {
// dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
// url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
pooled = true
dbCreate = "create-drop"//create-drop
driverClassName = "com.mysql.jdbc.Driver"
username = "***"
password = "***"
url="jdbc:mysql://127.0.0.1/MY_Dev"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}
any recommendations to solve this ?
i'm trying to connect grails to mysql but i get this error:
| Loading Grails 2.4.4 | Error There was an error loading the
BuildConfig: Bad artifact coordinates mys
ql:mysql-connector-java-5.1.23-bin, expected format is
<groupId>:<artifactId>[:< extension>[:<classifier>]]:<version(Use
--stacktrace to see the full trace)
| Configuring classpath | Error Resolve error obtaining dependencies:
Could not find artifact mysql:mysq l-connector-java:jar:5.1.23-bin in
grailsCentral (htts://repo.grails.org/grails /plugins) (Use
--stacktrace to see the full trace) | Error Resolve error obtaining dependencies: Could not find artifact mysql:mysq
l-connector-java:jar:5.1.23-bin in grailsCentral
(htts://repo.grails.org/grails /plugins) (Use --stacktrace to see the
full trace) | Error Could not find artifact
mysql:mysql-connector-java:jar:5.1.23-bin in gra ilsCentral
(htts://repo.grails.org/grails/plugins) | Run 'grails
dependency-report' for further information.
how can i fix this error ?
here is my buidconfig:
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0) grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level =1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256] ]
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "htt://repository.codehaus.org"
//mavenRepo "htt://download.java.net/maven/2/"
//mavenRepo "htt://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
runtime 'mysql:mysql-connector-java:5.1.23-bin'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:1.9.9"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
// Uncomment these to enable additional asset-pipeline capabilities
//compile ":sass-asset-pipeline:1.9.0"
//compile ":less-asset-pipeline:1.10.0"
//compile ":coffee-asset-pipeline:1.8.0"
//compile ":handlebars-asset-pipeline:1.3.0.3"
}
}
and datasource:
dataSource {
pooled = true
jmxExport = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5Dialect"
username = "root"
password = "thanh" } hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false // cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context }
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql:/localhost:3306/bkavr"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql:/localhost:3306/bkav"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql:/localhost:3306/bkav"
properties {
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}
Change runtime 'mysql:mysql-connector-java:5.1.23-bin'
to
runtime 'mysql:mysql-connector-java:5.1.34'
That should pull in the dependency correctly.