Comments (12)
Hmm. Assuming you have the import statement, in your build script, it should work.
You can try using the full classname:
String projectName = templates.TemplatesPlugin.prompt('Project Name:')
from gradle-templates.
I get the same error
I am new to groovy programming. I have placed the grade-templates-1.3.jar under <gradle_installation>/lib and also under <gradle_installation>/lib/plugins .
I am using gradle 1.4
gradle createMyProject
:createMyProject FAILED
FAILURE: Build failed with an exception.
-
Where:
Build file '/Users//Desktop/sample_projects/try_out_gradle_templates/build.gradle' line: 13 -
What went wrong:
Execution failed for task ':createMyProject'.Could not find property 'templates' on task ':createMyProject'.
-
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: 12.643 secs
from gradle-templates.
In order to import classes within build script is there any other setting to be done ?
This might be a basic question - appreciate your help in getting this resolved.
from gradle-templates.
That method of installation doesn't work with Gradle 1+. Actually, could you please tell me where you learned of that method? It's been removed from the project home page, and the old wiki location points to the new project home page. Would like to figure out if I missed some documentation somewhere. :)
You need to use the "apply from" method described on the project home page: https://github.com/townsfolk/gradle-templates
Basically, your build.gradle file should look something like this:
apply from: 'http://www.tellurianring.com/projects/gradle-plugins/gradle-templates/apply.groovy'
import templates.*
task 'createMyProject' << {
String projectName = TemplatesPlugin.prompt('Project Name:')
ProjectTemplate.fromRoot(projectName) {
'src/com/example' {}
'build.gradle' '''
apply plugin: 'java'
sourceSets {
main {
java {
srcDir 'src'
}
}
}
'''
}
}
from gradle-templates.
I have cut and pasted the same build.gradle and get the error again.
I tried the below settings in init.gradle
gradle.beforeProject { prj ->
prj.apply from: 'http://www.tellurianring.com/projects/gradle-plugins/gradle-templates/apply.groovy'
}
but get the same error.
from gradle-templates.
Reg the method of installation , I just tried few other means of installing the plugins from different forums. Your documentation is clear.
from gradle-templates.
Custom project structures won't work with the global install. You might be able to add createMyProject task within the init.gradle script, not sure if that'll work.
prj.task "createMyProject" << { .... }
I am seeing the same error you are now. Not sure what's broken, but I'll get back to you.
Thanks!
from gradle-templates.
Thanks a lot as this would be very useful in our project.
from gradle-templates.
Looks like the apply script no longer adds the classes to your build script. I can't find another workaround besides putting the contents of the apply script directly into your build script.
If you want your 'createMyProject' task, and all the other templates, replace the 'apply from' line with the following:
buildscript {
repositories {
ivy {
name = 'gradle_templates'
artifactPattern 'http://tellurianring.com/projects/gradle-plugins/[module]/[revision]/[artifact]-[revision].[ext]'
ivyPattern 'http://tellurianring.com/projects/gradle-plugins/[module]/[revision]/[artifact]-[revision].[ext]'
}
}
dependencies {
classpath 'gradle-templates:gradle-templates:1.3'
}
}
// Check to make sure templates.TemplatesPlugin isn't already added.
if (!project.plugins.findPlugin(templates.TemplatesPlugin)) {
project.apply(plugin: templates.TemplatesPlugin)
}
If you don't want the other templates, you can remove the final if check:
buildscript {
repositories {
ivy {
name = 'gradle_templates'
artifactPattern 'http://tellurianring.com/projects/gradle-plugins/[module]/[revision]/[artifact]-[revision].[ext]'
ivyPattern 'http://tellurianring.com/projects/gradle-plugins/[module]/[revision]/[artifact]-[revision].[ext]'
}
}
dependencies {
classpath 'gradle-templates:gradle-templates:1.3'
}
}
Either of these will work for creating your own tasks, you only need the if check if you want to use the base templates as well.
from gradle-templates.
Thanks. I will try this.
from gradle-templates.
I'm going assume this issue is closed, please reopen if you still experience issues.
from gradle-templates.
Thanks. Its working. This was really useful.
The issue can be closed.
from gradle-templates.
Related Issues (20)
- How to create Dynamic Web Project using Gradle Template plugin? HOT 3
- Create a GitHub pages site for project HOT 1
- Add license template options
- Layered and/or mixin approach to templates
- Setup Drone.io Build for project
- Allow installation of core only
- Create tests with classes
- Does the Gradle Init plugin make this obsolete HOT 1
- PromptOptions display prompt twice
- PromptOptions display defaultValue twice
- DefaultValue in promptOptions cause error
- Is this project still maintained? HOT 2
- Does not work with Gradle 4.0.7
- Does not work with Gradle 4.0.7 HOT 4
- Add gradlew configuration to build file templates.
- Move binary file artifacts over to sonatype HOT 5
- Release version 1.5
- Unable to execute initScalaProject task HOT 3
- setupBuild --type HOT 3
- Convert to standardized license? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gradle-templates.