Comments (17)
project group can not be changed from
com.sysgears.grain
. Main class name is bound to it and it seams that some internal features as well, because project would not compile if group name is changed.
Nothing is bound to com.sysgears.grain
group inside themes. Please clarify. How code compilation can be bound to any specific group? It's not possible at all. It's just plain Groovy code.
from grain.
groovy source code classes are bound to com\sysgears\theme\ directory. I tried to move them to another directory and change imports in SiteConfig, but got some NPEs. It is not very easy to access these files and I do not see any reason for complicated directory structure since there are no name conflicts. I also do not understand the purpose of Launcher.java class since it just point to some internal launcher.
The fact that you weren't able to move something to another directory doesn't mean that anything is bound to specific directory layout. Nothing in Grain is bound to specific layout structure. Please read documentation carefully.
from grain.
SiteConfig.groovy
has direct class imports which is not very good idea if it is intended as a configuration file. If one moves this classes or uses custom ones, he should replace all imports? It is better to use fully qualified class names and reflects to invoke user classes.
SiteConfig.groovy
is just a Groovy file. What is inside it is a responsibility of theme author. It can hold direct imports or can use qualified class names. What it has to do with Grain at all?
from grain.
generally in gradle all temporary files and build results are stored inside
build
directory. Is there a reason to store target and caches in project root? If they are all in one directory, than it is easier to clean.
Grain is not a gradle plugin. Grain can work as a gradle plugin, but it can work standalone as well. Grain cache files have nothing to do with the build cycle. They are in the Grain rendering cycle and they are not build files, rather they are cache files.
from grain.
For gradle plugin related issues, please open issue at:
https://github.com/sysgears/grain-gradle-plugin
from grain.
I mean that if I change the group, it won't compile.
The obvious reason is that string: mainClassName = [project.group, 'Main'].join('.')
. It references com.sysgears.grain.Main
class which is not exposed to the user. It tried to set main class manually like mainClassName = com.sysgears.grain.Main
. But it still won't work causing some NullPointerException
.
SiteConfig.groovy
is used by internal grain classes and so it is a part of grain framework. Can I create theme without this file? I tried to move classes referenced by SiteConfig
to another directory and change imports but it throws
Caused by: java.lang.NullPointerException
at org.eclipse.jetty.util.resource.ResourceCollection.<init>(ResourceCollection.java:98)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:74)
at org.codehaus.groovy.runtime.callsite.ConstructorSite.callConstructor(ConstructorSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
at com.sysgears.grain.preview.SitePreviewer.start(SitePreviewer.groovy:90)
from grain.
I mean that if I change the group, it won't compile.
The obvious reason is that string: mainClassName = [project.group, 'Main'].join('.'). It references com.sysgears.grain.Main class which is not exposed to the user. It tried to set main class manually like mainClassName = com.sysgears.grain.Main
Yes, it's the problem in the logic of the theme. mainClassName shouldn't be computed this way. I'm not sure though, why NPE if you set mainClassName directly. Have you set it as a string? i.e.:
mainClassName = "com.sysgears.grain.Main"
from grain.
OK, tried that again, and this time it worked. Probably last time I changed source code directory as well or forgot the quotes.
from grain.
SiteConfig.groovy
is used by internal grain classes and so it is a part of grain framework. Can I create theme without this file? I tried to move classes referenced by SiteConfig to another directory and change imports but it throws
To what directory did you tried to move which imports? Please be more specific. Please keep in mind, that Grain is not bound to com.sysgears group, but general Groovy class finding rules still apply.
from grain.
OK, tried that again, and this time it worked. Probably last time I changed source code directory as well or forgot the quotes.
Yep, I also thought, it's missing quotes...
from grain.
I moved files directly to src
(without changing source directory location in configuration). So import com.sysgears.theme.ResourceMapper
should be transformed to ResourceMapper
. Import from the same package is unnecessary, but it still should work.
from grain.
You should still have some package name, not default one as your classes will be accessed by Grain, which has named package:
http://stackoverflow.com/questions/283816/how-to-access-java-classes-in-the-default-package
It's a Java-thing, has nothing to do with Grain itself...
from grain.
After some experimenting, I forced it to work.
What one need is:
- non-default package
- change imports
- change package names
I still do not understand, what Launcher.java
does. Preview obviously works without it.
from grain.
Launcher.java
is for more convenient IDE integration. It's referenced in the docs. The purpose is to let user just import the gradle project with Grain theme, then right-click on Launcher.java and select Run to run the preview.
from grain.
Some IDEs have poor support for Groovy, hence Launcher.java
should be supported by most IDEs, even those that don't know about Groovy at all
from grain.
OK, it solves most of problems. Still, constructing my own theme is not overwhelmingly convenient, but I suppose this is the opposite side of flexibility.
Currently, I am working on my second project using Grain (first one here), so I wish you luck in future development.
from grain.
Yes, we are aware that it's cumbersome at times. But as you mentioned, the flexibility was the first priority. And wrapping flexibility into ease of use will require more effort.
Thanks for sharing info about your projects, feel free to ask questions. Please consider posting into Grain user group as well:
https://groups.google.com/forum/#!forum/grain-user
from grain.
Related Issues (19)
- Unable to specify proxy for Downloading SetupTools HOT 2
- NPE when invoking generate HOT 12
- Huge dependency download time and obsolete dependencies HOT 9
- The option to split Yaml & content HOT 3
- Different `index.html` reference in preview and generate HOT 8
- Crash during preview HOT 1
- Cache Busting HOT 2
- `application.properties` should be optional HOT 7
- `page.url` ignores directory in site url
- Injection declared but never used
- Freezes somewhere inside Ruby on generate
- Java 9 compatibility HOT 1
- Display a nice error for commands instead of a stack trace HOT 2
- Dependency problem HOT 2
- Customizing resource mapping to add new binary types HOT 2
- Help to integrate Jekill module to import wordpress sites HOT 2
- allow SiteConfig to specify attributes for Asciidoctor.convert HOT 3
- StackOverflow during generate HOT 3
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 grain.