Reputation: 2242
I am using gradle as project dependency manager but since I like netbeans better and can't find a native integration with maven, I copy the default pom generated by gradle as the pom.xml. But How do I set the source and target level?
my build.gradle looks like
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'java'
targetCompatibility=1.6
sourceCompatibility=1.6
after I run
gradle install
and check the build/poms/pom-default.xml it never configures the source nor target level which is defaulted to 1.3
what I am lacking is maven compiler plugin configuration
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
and haven't been able to find how to configure that specific part of the pom. I've found all the examples where they configure license, developer stuff and so on but not the plugin specif.
Upvotes: 1
Views: 2077
Reputation: 2242
took me a while to figure it out. Like Peter said above you can just add that section. Easier said than done though, at least for me.
Fortunately, spring is using gradle so you have lots of real world examples. check git hub
install {
repositories.mavenInstaller {
customizePom(pom, project)
}
}
def customizePom(pom, gradleProject) {
pom.whenConfigured { generatedPom ->
// respect 'optional' and 'provided' dependencies
gradleProject.optionalDeps.each { dep ->
generatedPom.dependencies.find { it.artifactId == dep.name }?.optional = true
}
gradleProject.providedDeps.each { dep ->
generatedPom.dependencies.find { it.artifactId == dep.name }?.scope = 'provided'
}
// eliminate test-scoped dependencies (no need in maven central poms)
generatedPom.dependencies.removeAll { dep ->
dep.scope == 'test'
}
// add all items necessary for maven central publication
generatedPom.project {
name = gradleProject.description
description = gradleProject.description
organization {
name = 'bajoneando'
}
build {
plugins {
plugin {
groupId = 'org.apache.maven.plugins'
artifactId = 'maven-compiler-plugin'
configuration {
source = '1.6'
target = '1.6'
}
}
plugin {
groupId = 'org.apache.maven.plugins'
artifactId = 'maven-surefire-plugin'
configuration {
includes {
include = '**/*Tests.java'
}
excludes {
exclude = '**/*Abstract*.java'
}
}
}
}
resources {
resource {
directory = 'src/main/java'
includes = ['**/*']
excludes = ['**/*.java']
}
resource {
directory = 'src/main/resources'
includes = ['**/*']
}
}
testResources {
testResource {
directory = 'src/test/java'
includes = ['**/*']
excludes = ['**/*.java']
}
testResource {
directory = 'src/test/resources'
includes = ['**/*']
}
}
}
developers {
developer {
id = 'lnramirez'
name = 'Luis Ramirez Monterosa'
email = '*****@gmail.com'
}
}
}
}
}
Upvotes: 3
Reputation: 123910
You can add that section in the very same way as the examples do it for "license and developer stuff".
Upvotes: 1