I am trying to use DexGuard plugin in Java project whith Gradle. It is library project for android.
But i want to link DexGuard library whitout:
apply plugin: 'com.android.application'
Because I need to use:
apply plugin: 'java'
Is it possible to use DexGuard plugin such a way?
I need this way to use because i need to use an additional plugin:
apply plugin: 'com.github.johnrengelman.shadow'
And I have a problem to use this plugin in conjunction whith android plugin...
My gradle:
buildscript {
repositories {
jcenter()
flatDir dirs: 'DexGuard/lib'
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.2'
classpath ':dexguard'
}
}
apply plugin: 'java'
apply plugin: 'com.github.johnrengelman.shadow'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '**/*.jar')
}
sourceSets {
main {
java.srcDirs = ['src']
}
}
shadowJar {
...
}
task sdkDexguard(type: com.saikoa.dexguard.gradle.DexGuardTask) {
configuration 'dexguard.txt'
injars 'build/classes'
injars 'libs'
outjars 'build/application.apk'
}
I can not to build tasklist. Error in line task sdkDexguard:
Could not find property 'com' on root project
UPD
Problem in the library DexGuard 6.1.11 for standalone usage. GuardSquare team will solve that soon.
Problem solved in version 7.0.31. Now possible to use this method for standalone usage.
Related
Trying out to use ObjectBox as java desktop database. However after following the documentation on the web site https://docs.objectbox.io/java-desktop-apps its not working. No MyObjectBox found error.
I am using eclipse ide Version: 2020-09 (4.17.0), Gradle: gradle-6.7.1
ObjectBox seems not creating the model automatically after build (no model folder generated). I have created the class using the Entity annotation, build the project eclipse, nothing happens. Anyone any ideas?
Works in android but not desktop. As i am not familiar with gradle project in eclipse. the following is the build file
buildscript {
ext.objectboxVersion = '2.8.1'
repositories {
jcenter()
}
dependencies {
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
}
}
apply plugin: 'java-library'
apply plugin: 'io.objectbox'
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
repositories {
jcenter()
}
dependencies {
implementation "io.objectbox:objectbox-linux:$objectboxVersion"
implementation "io.objectbox:objectbox-macos:$objectboxVersion"
implementation "io.objectbox:objectbox-windows:$objectboxVersion"
}
apply plugin: 'io.objectbox'
dependencies {
implementation "io.objectbox:objectbox-java:$objectboxVersion"
annotationProcessor "io.objectbox:objectbox-processor:$objectboxVersion"
}
apply plugin: 'io.objectbox'
Doing apply plugin: 'io.objectbox' three times does not look good. Once is enough. Please check the ObjectBox Java examples for a working setup. In your case have a closer look at the java-main example for standalone Java applications.
This is the basic structure with ... where I left out the details (check the full build.gradle file from the example):
buildscript {
...
}
apply plugin: 'java'
apply plugin: 'application'
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
mainClassName = "io.objectbox.example.Main"
dependencies {
...
}
// Apply plugin after dependencies block so they are not overwritten.
apply plugin: 'io.objectbox'
Maybe checkout the example and start from there?
I have groovy application that i want to pack in executable jar with gradle.
The problem is when the jar is done i have error: Could not find or load main class .
Here is my build.gradle:
group 'com.demo'
version '1.0-SNAPSHOT'
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin:'application'
mainClassName = 'com.demo.App'
buildscript {
repositories {
mavenCentral()
}
dependencies {}
}
repositories {
mavenCentral()
}
// java version dependency
sourceCompatibility = 1.8
targetCompatibility = 1.8
jar {
baseName = 'cim-configurator'
version = '0.1.0'
manifest {
attributes("Build-Time": new Date().format("yyyy-MM-dd HH:mm:ss"),
"Build-Jdk": System.getProperty("java.version"),
"Built-By": System.getProperty("user.name"),
"Created-By": "Gradle",
"Main-Class": "com.demo.App"
)
}
}
Here is the file hierarchy:
com.demo
ActiveMq
App
Database
Rbac
Run.groovy
Service
I think that using uberjar will fix your problem. It worked with similar case for me.
I had this exact same problem in a Groovy & Gradle project. This is the answer that fixed this problem.
TL;DR
Use the Shadow-jar plugin by adding the following plugin to your plugins block in build.gradle:
plugins {
id 'com.github.johnrengelman.shadow' version '5.0.0'
}
Then run ./gradlew shadowJar
You'll get a jar file emailer-all.jar, which can be run.
After a lot of searching, it was the last option to raise it here! In eclipse, I am designing such project structure using Gradle, as shown below...
Algorithms //Parent Project
-SubModuleCore //Child Project for common utilities & dependencies
-build.gradle
-SubModuleOne //Child project for any operation
-build.gradle //Added 'SubModuleCore' as a dependency like compile project(':SubModuleCore')
-SubModuleTwo //Child project for another operation
-build.gradle //Added 'SubModuleCore' as a dependency like compile project(':SubModuleCore')
-build.gradle
-settings.gradle
Services //Stand-Alone project
-build.gradle //Here I want to add 'Algorithms' as a single dependency
-settings.gradle
Project structures are same in eclipse work-space as shown above. I am able to generate individual .jar of Algorithms project. So the problem is I want to add this Algorithms project as a single dependency in project Services like compile project(':Algorithms'). But eclipse just saying 'shut-up!'. I don't want to publish it somewhere like maven central / jitpack etc. instead I want to do it locally. I'm trying this way...
Services/build.gradle
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
project.webAppDirName = 'WebContent'
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile fileTree(dir: 'lib', include: ['*.jar'])
compile project(':Algorithms')
}
Services/settings.gradle
rootProject.name = 'Services'
include 'Algorithms'
project(':Algorithms').projectDir = new File(settingsDir, '../Algorithms')
Algorithms/build.gradle
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = "1.8";
targetCompatibility = "1.8";
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = "1.8";
targetCompatibility = "1.8";
buildscript {
dependencies {
repositories {
jcenter()
mavenCentral()
}
}
}
repositories {
jcenter()
mavenCentral()
}
}
subprojects.each { subproject ->
evaluationDependsOn(subproject.path)
}
jar.dependsOn subprojects.tasks['classes']
jar {
baseName = 'algorithms'
subprojects.each { subproject ->
from subproject.sourceSets.main.output.classesDir
}
from files('resources/log4j2.xml')
from files('resources/application.properties')
}
Algorithms/settings.gradle
rootProject.name = 'Algorithms'
include ':SubModuleCore', ':SubModuleOne', ':SubModuleTwo'
I tried several solutions from SO, still not succeeded. Somebody please help me, I got stuck badly here. It seems I am very close to this, but don't know what is missing!
Thanks
You can use the includeBuild feature.
Declare the included build in Services/settings.gradle
rootProject.name='Services'
includeBuild '../Algorithms'
and then express the dependency using
compile "${project.group}:${project.name}"
where project group and name the one from the Algorithms project.
When I build a project in console I have no service of type styled text output factory available in project scope service. I have also a file pom.xml .I don't know what I do it wrong
This is my build.gradle :
import java.sql.Wrapper
buildscript {
ext {
springBootVersion = '1.2.5.RELEASE'
}
repositories {
maven { url "http://repo.spring.io/libs-milestone" }
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
war {
baseName = 'springboot'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-milestone" }
}
configurations {
providedRuntime
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("javax.servlet:jstl:1.2")
runtime("mysql:mysql-connector-java")
compile("org.springframework.boot:spring-boot-starter-jdbc")
// https://mvnrepository.com/artifact/javax.el/el-api
compile group: 'javax.el', name: 'el-api', version: '2.2.1-b04'
compile ("org.springframework.boot:spring-boot-starter-web")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
providedRuntime 'org.apache.tomcat.embed:tomcat-embed-jasper'
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
I believe the problem is a function of the versions of Gradle and Spring's dependency-management-plugin that are in use.
See the original report from the Spring guys in this Bug in Gradle 2.14-rc1 - No service of type StyledTextOutputFactory report. Gradle moved the StyledTextOutputFactory to an internal package at some point (for the 3.0 release), which broke dependency-management-plugin 0.5.x.
This dependency-management-plugin issue details their making changes to address this in their 0.6.0 release.
I see your build script references Gradle 2.3...but I'm wondering if that is accurate.
I think it boils down to either use Gradle 2.x with dependency-management-plugin 0.5.x or use Gradle 3.x with dependency-management-plugin 0.6.x.
Good luck.
I have a java project that write in kotlin ,i use intelliJ IDEA to develop this project. I have trouble on the dependencies setting (multiple project). I already read lot of examples , but I can't find the workaround , here is my dependencies setting code,
it can be build in java class correctly , but the kotlin class will get lot of error 'Unresolved reference' . Is that any wrong about my setting or gradle is not suitable with kotlin .
PS : when i only build core project , build process will successful , but build at test project will get the reference unresolved error
allprojects {
apply plugin: 'java'
apply plugin: 'kotlin'
group 'testProject'
version '1.0'
}
subprojects{
apply plugin: 'java'
apply plugin: 'kotlin'
def defaultEncoding = 'UTF-8'
compileJava.options.encoding = defaultEncoding
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
// Kotlin
compile "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
}
project(':test') {
dependencies {
compile project(':core')
compile project(':testTwo')
}
project(':testTwo'){
dependencies{
compile project(':core')
}
setting.gradle
include 'test','testTwo','core'
The kotlin-gradle-plugin is not a dependency of your subprojects, it is a dependency of the buildscript itself.
Follow the instructions on Plugin and Versions